Example #1
0
 def __call__(self, req):
     if req.content_type == 'application/xml':
         serializer = wsgi.XMLResponseSerializer()
     else:
         serializer = wsgi.JSONResponseSerializer()
     resp = webob.Response(request=req)
     default_webob_exc = webob.exc.HTTPInternalServerError()
     resp.status_code = self.error.get('code', default_webob_exc.code)
     serializer.default(resp, self.error)
     return resp
Example #2
0
 def __init__(self, detail=None):
     '''
     Overload HTTPError constructor, so we can create a default serialized
     body.  This is required because not all error responses are processed
     by the wsgi controller (ie auth errors, which are further up the
     paste pipeline.  We serialize in XML by default (as AWS does)
     '''
     webob.exc.HTTPError.__init__(self, detail=detail)
     serializer = wsgi.XMLResponseSerializer()
     serializer.default(self, self.get_unserialized_body())