def _dispatch(req): """Dispatch a Request. Called by self._router after matching the incoming request to a route and putting the information into req.environ. Either returns 404 or the routed WSGI app's response. """ match = req.environ['wsgiorg.routing_args'][1] if not match: language = req.best_match_language() msg = _('The resource could not be found.') msg = gettextutils.get_localized_message(msg, language) return webob.exc.HTTPNotFound(explanation=msg) app = match['controller'] return app
def __call__(self, req): """Respond to a request for all Neutron API versions.""" version_objs = [ { "id": "v2.0", "status": "CURRENT", }, ] if req.path != '/': language = req.best_match_language() msg = _('Unknown API version specified') msg = gettextutils.get_localized_message(msg, language) return webob.exc.HTTPNotFound(explanation=msg) builder = versions_view.get_view_builder(req) versions = [builder.build(version) for version in version_objs] response = dict(versions=versions) metadata = { "application/xml": { "attributes": { "version": ["status", "id"], "link": ["rel", "href"], } } } content_type = req.best_match_content_type() body = (wsgi.Serializer(metadata=metadata). serialize(response, content_type)) response = webob.Response() response.content_type = content_type response.body = body return response
def __call__(self, req): """Respond to a request for all Neutron API versions.""" version_objs = [ { "id": "v2.0", "status": "CURRENT", }, ] if req.path != '/': language = req.best_match_language() msg = _('Unknown API version specified') msg = gettextutils.get_localized_message(msg, language) return webob.exc.HTTPNotFound(explanation=msg) builder = versions_view.get_view_builder(req) versions = [builder.build(version) for version in version_objs] response = dict(versions=versions) metadata = { "application/xml": { "attributes": { "version": ["status", "id"], "link": ["rel", "href"], } } } content_type = req.best_match_content_type() body = (wsgi.Serializer(metadata=metadata).serialize( response, content_type)) response = webob.Response() response.content_type = content_type response.body = body return response