diff options
author | Rajaram Mallya <rajarammallya@gmail.com> | 2011-08-30 14:09:14 +0530 |
---|---|---|
committer | Rajaram Mallya <rajarammallya@gmail.com> | 2011-08-30 14:09:14 +0530 |
commit | 7f842efba56125e0903a13a9e50a925adef48bc2 (patch) | |
tree | a77fddda5bae4b02010f538e274552823bc942ce /openstack | |
parent | 0789e762583f3b306aa50c8c74c48256e731eb6c (diff) | |
download | oslo-7f842efba56125e0903a13a9e50a925adef48bc2.tar.gz oslo-7f842efba56125e0903a13a9e50a925adef48bc2.tar.xz oslo-7f842efba56125e0903a13a9e50a925adef48bc2.zip |
Rajaram/Vinkesh| restructured wsgi.resource to allow inheriting classes to override serialization, deserialization and action execution
Diffstat (limited to 'openstack')
-rw-r--r-- | openstack/common/wsgi.py | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/openstack/common/wsgi.py b/openstack/common/wsgi.py index ef132dc..8faa6dc 100644 --- a/openstack/common/wsgi.py +++ b/openstack/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: |