~rackspace-titan/nova/osapi-xml-validation

« back to all changes in this revision

Viewing changes to nova/api/openstack/wsgi.py

  • Committer: Brian Waldon
  • Date: 2011-05-19 00:33:25 UTC
  • Revision ID: brian.waldon@rackspace.com-20110519003325-uaxd2ole5ypuezar
removing controller/serializer code from wsgi.py; updating other code to use new modules

Show diffs side-by-side

added added

removed removed

Lines of Context:
206
206
        except exception.InvalidContentType:
207
207
            return webob.exc.HTTPBadRequest(_("Unsupported Content-Type"))
208
208
 
209
 
        controller_method = getattr(self.controller, action)
210
 
        result = controller_method(req=request, **action_args)
 
209
        result = self.dispatch(request, action, action_args)
211
210
 
212
211
        response = self.serialize_response(accept, result)
213
212
 
222
221
 
223
222
        return response
224
223
 
 
224
    def dispatch(self, request, action, action_args):
 
225
        controller_method = getattr(self.controller, action)
 
226
        return controller_method(req=request, **action_args)
 
227
 
225
228
    def serialize_response(self, content_type, response_body):
226
229
        """Serialize a dict into a string and wrap in a wsgi.Request object.
227
230
 
253
256
 
254
257
        """
255
258
        action_args = self.get_action_args(request.environ)
256
 
        action = action_args.pop('action')
 
259
        action = action_args.pop('action', None)
257
260
 
258
261
        if request.method.lower() in ('post', 'put'):
259
262
            if len(request.body) == 0:
275
278
        return request.best_match_content_type()
276
279
 
277
280
    def get_action_args(self, request_environment):
278
 
        args = request_environment['wsgiorg.routing_args'][1].copy()
279
 
 
280
 
        del args['controller']
281
 
 
282
 
        if 'format' in args:
283
 
            del args['format']
284
 
 
285
 
        return args
 
281
        try:
 
282
            args = request_environment['wsgiorg.routing_args'][1].copy()
 
283
 
 
284
            del args['controller']
 
285
 
 
286
            if 'format' in args:
 
287
                del args['format']
 
288
 
 
289
            return args
 
290
 
 
291
        except KeyError:
 
292
            return {}
286
293
 
287
294
    def get_deserializer(self, content_type):
288
295
        try: