Beispiel #1
0
    def getChild(self, name, request):
        # deserialize post json data
        if request.method.lower() in ('post', 'put'):
            content = request.content.read()
            try:
                decoded = loads(content)
                request.params = decoded
            except ValueError:
                return BadRequestResponse('Could not decode JSON encoded parameters.')
        else:
            request.params = dict((k,v[0]) for (k,v) in request.args.iteritems())

        try:
            resc = APIResource.getChild(self, name, request)
            if resc is None:
                return NotFoundResponse()
            return resc
        # catch bubbled error responses
        except JsonResponse, e:
            # and return them
            return e