'WSGI method that controls (de)serialization and method dispatch.'

@webob.dec.wsgify(RequestClass=Request)
def __call__(self, request):

    action_args = self.get_action_args(request.environ)
    action = action_args.pop('action', None)
    body_reject = strutils.bool_from_string(action_args.pop('body_reject', None))
    try:
        if (body_reject and self.deserializer.has_body(request)):
            msg = _('A    body    is    not    expected    with    this    request.')
            raise webob.exc.HTTPBadRequest(explanation=msg)
        deserialized_request = self.dispatch(self.deserializer, action, request)
        action_args.update(deserialized_request)
        action_result = self.dispatch(self.controller, action, request, **action_args)
    except webob.exc.WSGIHTTPException as e:
        exc_info = sys.exc_info()
        e = translate_exception(request, e)
        six.reraise(type(e), e, exc_info[2])
    except UnicodeDecodeError:
        msg = _('Error    decoding    your    request.    Either    the    URL    or    the    request    body    contained    characters    that    could    not    be    decoded    by    Glance')
        raise webob.exc.HTTPBadRequest(explanation=msg)
    except Exception as e:
        LOG.exception(_LE('Caught    error:    %s'), encodeutils.exception_to_unicode(e))
        response = webob.exc.HTTPInternalServerError()
        return response
    try:
        response = webob.Response(request=request)
        self.dispatch(self.serializer, action, response, action_result)
        for (name, value) in list(response.headers.items()):
            if (six.PY2 and isinstance(value, six.text_type)):
                response.headers[name] = encodeutils.safe_encode(value)
        return response
    except webob.exc.WSGIHTTPException as e:
        return translate_exception(request, e)
    except webob.exc.HTTPException as e:
        return e
    except Exception:
        return action_result
