summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRajaram Mallya <rajarammallya@gmail.com>2011-08-30 14:09:14 +0530
committerRajaram Mallya <rajarammallya@gmail.com>2011-08-30 14:09:14 +0530
commitadc495d106242a77daca1d2decdb4ac1d11e85be (patch)
treee9593aaa793154e274e1a2084f16c68d6c14250f
parent00d9697873e36019681392c9077c615c8c19f099 (diff)
Rajaram/Vinkesh| restructured wsgi.resource to allow inheriting classes to override serialization, deserialization and action execution
-rw-r--r--common/wsgi.py25
1 files changed, 16 insertions, 9 deletions
diff --git a/common/wsgi.py b/common/wsgi.py
index ef132dc..8faa6dc 100644
--- a/common/wsgi.py
+++ b/common/wsgi.py
@@ -302,21 +302,28 @@ class Resource(object):
action_args = self.get_action_args(request.environ)
action = action_args.pop('action', None)
- deserialized_request = self.dispatch(self.deserializer,
- action, request)
- action_args.update(deserialized_request)
-
- action_result = self.dispatch(self.controller, action,
- request, **action_args)
+ deserialized_params = self.deserialize_request(action, request)
+ action_args.update(deserialized_params)
+ action_result = self.execute_action(action, request, **action_args)
try:
- response = webob.Response()
- self.dispatch(self.serializer, action, response, action_result)
- return response
+ return self.serialize_response(action, action_result, request)
# return unserializable result (typically a webob exc)
except Exception:
return action_result
+ def deserialize_request(self, action, request):
+ return self.dispatch(self.deserializer, action, request)
+
+ def serialize_response(self, action, action_result, request):
+ response = webob.Response()
+ self.dispatch(self.serializer, action, response,
+ action_result, request)
+ return response
+
+ def execute_action(self, action, request, **action_args):
+ return self.dispatch(self.controller, action, request, **action_args)
+
def dispatch(self, obj, action, *args, **kwargs):
"""Find action-specific method on self and call it."""
try: