def create_resource(controller, options=None): body_deserializers = {'application/json': wsgi.JSONDeserializer()} deserializer = wsgi.RequestDeserializer( body_deserializers=body_deserializers) body_serializers = {'application/json': wsgi.JSONDictSerializer()} serializer = wsgi.ResponseSerializer(body_serializers=body_serializers) return wsgi.Resource(controller, deserializer, serializer)
def __init__(self, controller, deserializer=None, serializer=None): if not deserializer: body_deserializers = { 'application/x-amz-json-1.0': wsgi.JSONDeserializer() } deserializer = (wsgi.RequestDeserializer( body_deserializers=body_deserializers)) if not serializer: body_serializers = { 'application/x-amz-json-1.0': wsgi.JSONDictSerializer() } serializer = (wsgi.ResponseSerializer( body_serializers=body_serializers)) super(AmazonResource, self).__init__(controller, deserializer=deserializer, serializer=serializer)
def __call__(self, req): serializer = wsgi.ResponseSerializer() resp = serializer.serialize(self.error, self.content_type) default_webob_exc = webob.exc.HTTPInternalServerError() resp.status_code = self.error.get('code', default_webob_exc.code) return resp