Example #1
0
def getChildForRequest(resource, request):
    # originally taken from twisted.web.resource
    """
    Traverse resource tree to find who will handle the request.
    """
    while request.postpath and not resource.isLeaf:
        pathElement = request.postpath.pop(0)
        request.prepath.append(pathElement)
        retval = resource.getChildWithDefault(pathElement, request)
        if isinstance(retval, defer.Deferred):
            resource = yield retval
        else:
            resource = retval
    defer.returnValue(resource)
Example #2
0
    def _getResource(self, args=None, headers=None, path=()):
        """
        Generalized GET for a particular resource.
        """
        headers = headers or correctAcceptHeaders
        request = _FakeRequest(args=args, requestHeaders=headers)

        resource = self.resource
        for childName in path:
            resource = resource.getChildWithDefault(childName, request)

        d = self._makeRequest(resource, request)

        @d.addCallback
        def verify(_):
            self._checkContentType()
            self._decodeResponse()

        return d
Example #3
0
    def _getResource(self, args=None, headers=None, path=()):
        """
        Generalized GET for a particular resource.
        """
        headers = headers or correctAcceptHeaders
        request = _FakeRequest(args=args, requestHeaders=headers)

        resource = self.resource
        for childName in path:
            resource = resource.getChildWithDefault(childName, request)

        d = self._makeRequest(resource, request)

        @d.addCallback
        def verify(_):
            self._checkContentType()
            self._decodeResponse()

        return d
Example #4
0
 def getChildWithDefault(self, name, request):
     d = defer.succeed(self.default)
     resource = util.DeferredResource(d)
     return resource.getChildWithDefault(name, request)
Example #5
0
 def getChildWithDefault(self, name, request):
     d = defer.succeed(self.default)
     resource = util.DeferredResource(d)
     return resource.getChildWithDefault(name, request)
Example #6
0
 def _getChild(self, resource, path, request):
     return resource.getChildWithDefault(path, request)
Example #7
0
 def _getChild(self, resource, path, request):
     return resource.getChildWithDefault(path, request)