diff options
author | Dolph Mathews <dolph.mathews@gmail.com> | 2012-02-28 00:08:07 -0600 |
---|---|---|
committer | Dolph Mathews <dolph.mathews@gmail.com> | 2012-02-28 00:08:16 -0600 |
commit | a7c8e2ab8186a01009a163e4c714ebec95e3cc4e (patch) | |
tree | 3918188e90ff968f6b823404d2752dd663e875f5 /keystone | |
parent | 9581809f88b953e361ef3451d410e568b606fcca (diff) | |
download | keystone-a7c8e2ab8186a01009a163e4c714ebec95e3cc4e.tar.gz |
Provide request to Middleware.process_response()
It appears that no middleware has taken advantage of
the builtin process_response(response) convention,
because a reference to the original request is
typically necessary to build an appropriate response.
Change-Id: If032261974eb1d756abdbd5b18892091978e2a07
Diffstat (limited to 'keystone')
-rw-r--r-- | keystone/common/wsgi.py | 14 | ||||
-rw-r--r-- | keystone/middleware/core.py | 7 |
2 files changed, 8 insertions, 13 deletions
diff --git a/keystone/common/wsgi.py b/keystone/common/wsgi.py index c75339f53..6279d4cc4 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 19212e0c9..7faa3f013 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 |