コード例 #1
0
ファイル: urlopener.py プロジェクト: PMR2/cellml.pmr2
    def loadURL(self, location, headers=None):
        p = urlparse.urlparse(location)
        if not p.scheme == 'pmr':
            # standard urls.
            return super(PmrUrlOpener, self).loadURL(location, headers=headers)

        # Fragments for the location of the object to be loaded are
        # delimited by colons.  Shouldn't contain any colons in any of
        # them, but the filepath might so we limit splits to two.
        objpath, rev, filepath = p.path.split(':', 2)

        # strip off the leading `/` hint for urljoin.
        filepath = filepath[1:]

        portal = getSite()
        workspace = portal.restrictedTraverse(objpath.split('/'))
        storage = IStorage(workspace)
        storage.checkout(rev)
        pathinfo = storage.pathinfo(filepath)
        if pathinfo.get('external'):
            kws = {}
            kws.update(pathinfo['external'])
            target = external_to_url(kws)
            return self.loadURL(target)
        # Using this instead of contents to ignore directories.
        return storage.file(filepath)
コード例 #2
0
ファイル: test_utility.py プロジェクト: PMR2/pmr2.omex
    def test_utility_base(self):
        utility = zope.component.getUtility(IStorageArchiver, name='omex')
        self.assertFalse(utility.enabledFor(
            IStorage(self.portal.workspace.test)))

        target = IStorage(self.portal.workspace.omex_base)
        self.assertFalse(utility.enabledFor(target))

        # on the revision with the root manifest.xml
        target.checkout('0')
        self.assertTrue(utility.enabledFor(target))
コード例 #3
0
ファイル: catalog.py プロジェクト: PMR2/pmr2.app
def pmr2_workspace_storage_roots(self):
    """
    Index the roots of all the underlying storage.
    """

    try:
        storage = IStorage(self)
        return storage.roots()
    except NotImplementedError:
        return []
    except Exception:
        logger.exception('failed to derive roots for storage of %s', self)
        return []
コード例 #4
0
ファイル: utility.py プロジェクト: PMR2/pmr2.omex
def OmexExposureArchiverFactory(exposure_object):
    # XXX only works with ExposureFile objects now.
    note = zope.component.getAdapter(exposure_object, name='omex')
    if note is None or note.path is None:
        return None

    try:
        exposure, workspace, path = zope.component.getAdapter(
            exposure_object, IExposureSourceAdapter).source()
        storage = IStorage(exposure)
        manifest = storage.file(path)
    except:
        return None

    archiver = partial(build_omex, storage, note.path)
    return archiver
コード例 #5
0
ファイル: test_utility.py プロジェクト: PMR2/pmr2.mercurial
 def test_0001_utility_base(self):
     utility = MercurialStorageUtility()
     storage = utility(self.workspace)
     self.assert_(isinstance(storage, MercurialStorage))
     self.assert_(IStorage.providedBy(storage))
コード例 #6
0
ファイル: test_utility.py プロジェクト: PMR2/pmr2.mercurial
 def test_000_storage(self):
     # Direct instantiation
     storage = MercurialStorage(self.workspace)
     self.assert_(IStorage.providedBy(storage))