'Call the method specified in req.environ by RoutesMiddleware.'

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

    arg_dict = req.environ['wsgiorg.routing_args'][1]
    action = arg_dict['action']
    method = getattr(self, action)
    del arg_dict['controller']
    del arg_dict['action']
    if ('format' in arg_dict):
        del arg_dict['format']
    arg_dict['request'] = req
    result = method(**arg_dict)
    if (isinstance(result, dict) or (result is None)):
        if (result is None):
            status = 204
            content_type = ''
            body = None
        else:
            status = 200
            content_type = req.best_match_content_type()
            body = self._serialize(result, content_type)
        response = webob.Response(status=status, content_type=content_type, body=body)
        LOG.debug('%(url)s    returned    with    HTTP    %(status)d', dict(url=req.url, status=response.status_int))
        return response
    else:
        return result
