diff --git a/keystone/common/wsgi.py b/keystone/common/wsgi.py index c75339f531..6279d4cc46 100644 --- a/keystone/common/wsgi.py +++ b/keystone/common/wsgi.py @@ -260,7 +260,7 @@ class Middleware(Application): def __init__(self, application): self.application = application - def process_request(self, req): + def process_request(self, request): """Called on each request. If this returns None, the next application down the stack will be @@ -270,17 +270,17 @@ class Middleware(Application): """ return None - def process_response(self, response): - """Do whatever you'd like to the response.""" + def process_response(self, request, response): + """Do whatever you'd like to the response, based on the request.""" return response @webob.dec.wsgify(RequestClass=Request) - def __call__(self, req): - response = self.process_request(req) + def __call__(self, request): + response = self.process_request(request) if response: return response - response = req.get_response(self.application) - return self.process_response(response) + response = request.get_response(self.application) + return self.process_response(request, response) class Debug(Middleware): diff --git a/keystone/middleware/core.py b/keystone/middleware/core.py index 19212e0c99..7faa3f0131 100644 --- a/keystone/middleware/core.py +++ b/keystone/middleware/core.py @@ -130,12 +130,6 @@ class JsonBodyMiddleware(wsgi.Middleware): class XmlBodyMiddleware(wsgi.Middleware): """De/serializes XML to/from JSON.""" - @webob.dec.wsgify(RequestClass=wsgi.Request) - def __call__(self, request): - self.process_request(request) - response = request.get_response(self.application) - self.process_response(request, response) - return response def process_request(self, request): """Transform the request from XML to JSON.""" @@ -153,3 +147,4 @@ class XmlBodyMiddleware(wsgi.Middleware): response.body = serializer.to_xml(json.loads(response.body)) except: raise exception.Error(message=response.body) + return response