def render(self): """ Renders the requested resource returned from the self.process() method. """ # traverse the resource tree child = getChildForRequest(self.env.tree, self) # check result and either render direct or in thread if IFileSystemResource.providedBy(child): # render direct return child.render(self) elif IStatical.providedBy(child): # render direct return child.render(self) elif IScriptResource.providedBy(child): msg = "Script resources may not be called via SFTP." raise ForbiddenError(msg) elif IRESTResource.providedBy(child): return child.render(self) elif IResource.providedBy(child): return child.render(self) msg = "I don't know how to handle this resource type %s" raise InternalServerError(msg % type(child))
def _readFile(self, filename, flags, attrs): # @UnusedVariable # read file via SFTP processor proc = SFTPProcessor(self.env) try: result = proc.run(GET, filename) except SeisHubError, e: raise SFTPError(FX_FAILURE, e.message) except: raise # set attributes try: self.attrs.update(result.getMetadata()) except: pass if IRESTResource.providedBy(result): # some REST resource try: data = result.render_GET(proc) except SeisHubError, e: raise SFTPError(FX_FAILURE, e.message) except: raise self.data = StringIO.StringIO(data) elif IFileSystemResource.providedBy(result): # some file system resource self.data = result.open() else: msg = "I don't know how to handle this resource type %s" raise SFTPError(FX_FAILURE, msg % type(result))