def childFactory(self, ctx, name): # 'name' is expected to be a URI try: node = self.client.create_node_from_uri(name) return directory.make_handler_for(node, self.client) except (TypeError, AssertionError): raise WebError("'%s' is not a valid file- or directory- cap" % name)
def childFactory(self, ctx, name): # 'name' is expected to be a URI try: node = self.client.create_node_from_uri(name) return directory.make_handler_for(node, self.client) except (TypeError, AssertionError): raise WebError("'%s' is not a valid file- or directory- cap" % name)
def getChild(self, name, req): """ Most requests look like /uri/<cap> so this fetches the capability and creates and appropriate handler (depending on the kind of capability it was passed). """ try: node = self.client.create_node_from_uri(name) return directory.make_handler_for(node, self.client) except (TypeError, AssertionError): raise WebError( "'{}' is not a valid file- or directory- cap".format(name))
def getChild(self, name, req): """ Most requests look like /uri/<cap> so this fetches the capability and creates and appropriate handler (depending on the kind of capability it was passed). """ # this is in case a URI like "/uri/?cap=<valid capability>" is # passed -- we re-direct to the non-trailing-slash version so # that there is just one valid URI for "uri" resource. if not name: u = DecodedURL.from_text(req.uri.decode('utf8')) u = u.replace( path=(s for s in u.path if s), # remove empty segments ) return redirectTo(u.to_uri().to_text().encode('utf8'), req) try: node = self.client.create_node_from_uri(name) return directory.make_handler_for(node, self.client) except (TypeError, AssertionError): raise WebError( "'{}' is not a valid file- or directory- cap".format(name))