]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Fix metadata startup.
authorIan Main <imain@redhat.com>
Fri, 22 Jun 2012 16:55:17 +0000 (09:55 -0700)
committerIan Main <imain@redhat.com>
Fri, 22 Jun 2012 17:14:37 +0000 (10:14 -0700)
A previous change to wsgi init caused the metadata to break.  This
makes the 4th argument to init optional allowing other wsgi apps to
continue to work as normal.

Change-Id: Ib0e7042f656a9319013dba4e30c7ffa35cb85f92
Signed-off-by: Ian Main <imain@redhat.com>
heat/common/wsgi.py

index dd92718a4b3f7f2db39301f575f6929dcc3faf08..992870a72d9128a6cd4b0170a01b9d72e645eb55 100644 (file)
@@ -481,14 +481,17 @@ class Resource(object):
     may raise a webob.exc exception or return a dict, which will be
     serialized by requested content type.
     """
-    def __init__(self, controller, deserializer):
+    def __init__(self, controller, deserializer, serializer=None):
         """
         :param controller: object that implement methods created by routes lib
         :param deserializer: object that supports webob request deserialization
                              through controller-like actions
+        :param serializer: object that supports webob response serialization
+                           through controller-like actions
         """
         self.controller = controller
         self.deserializer = deserializer
+        self.serializer = serializer
 
     @webob.dec.wsgify(RequestClass=Request)
     def __call__(self, request):
@@ -511,14 +514,19 @@ class Resource(object):
 
         action_result = self.dispatch(self.controller, action,
                                       request, **action_args)
+
+        # Here we support either passing in a serializer or detecting it
+        # based on the content type.
         try:
+            serializer = self.serializer
+            if serializer is None:
+                if content_type == "JSON":
+                    serializer = JSONResponseSerializer()
+                else:
+                    serializer = XMLResponseSerializer()
+
             response = webob.Response(request=request)
-            if content_type == "JSON":
-                self.dispatch(JSONResponseSerializer(),
-                    action, response, action_result)
-            else:
-                self.dispatch(XMLResponseSerializer(), action,
-                    response, action_result)
+            self.dispatch(serializer, action, response, action_result)
             return response
 
         # return unserializable result (typically a webob exc)