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)
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