msg = 'Expected a dictionary or basestring.' raise InternalServerError(msg) # build up a file list filelist = [] filelist.append(('.', {})) filelist.append(('..', {})) # cycle through all objects and add only known resources ids = sorted(result) for id in ids: obj = result.get(id) # skip hidden objects if obj.hidden: continue if IXMLIndex.providedBy(obj): continue if IAdminResource.providedBy(obj): continue attrs = obj.getMetadata() if attrs: # process uid try: attrs['uid'] = self.env.auth.getUser(attrs['uid']).uid except: attrs['uid'] = 0 # return ids in system encoding fsid = id.decode('utf-8').encode(sys.getfilesystemencoding()) filelist.append((fsid, attrs)) return DirList(self.env, iter(filelist)) def getAttrs(self, path, followLinks): """
except Exception, e: self.env.log.error(e) self.write('') self.finish() return # set default HTTP headers self.setHeader('server', 'SeisHub ' + SEISHUB_VERSION) self.setHeader('date', http.datetimeToString()) # result rendered? if result == server.NOT_DONE_YET: # resource takes care about rendering return # XXX: all or nothing - only authenticated are allowed to access # should be replaced with a much finer mechanism # URL, role and group based if not IAdminResource.providedBy(result) and \ self.env.auth.getUser('anonymous').permissions == 755: # skip for non administrative resources and allow anonymous access # if permission are set pass elif not result.public and not self.isAuthenticatedUser(): self.authenticate() return # check result and either render direct or in thread if IFileSystemResource.providedBy(result): # file system resources render direct data = result.render(self) if result.folderish: # check for default page for id in self.default_pages: if id in data and not data[id].folderish: