Example #1
0
    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.translate(msg, language)
            return webob.exc.HTTPNotFound(explanation=msg)
        app = match['controller']
        return app
Example #2
0
    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.translate(msg, language)
            return webob.exc.HTTPNotFound(explanation=msg)
        app = match["controller"]
        return app
Example #3
0
    def __call__(self, req):
        """Respond to a request for all Tacker API versions."""
        version_objs = [{"id": "v1.0", "status": "CURRENT"}]

        if req.path != "/":
            language = req.best_match_language()
            msg = _("Unknown API version specified")
            msg = gettextutils.translate(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
Example #4
0
    def __call__(self, req):
        """Respond to a request for all Tacker API versions."""
        version_objs = [
            {
                "id": "v1.0",
                "status": "CURRENT",
            },
        ]

        if req.path != '/':
            language = req.best_match_language()
            msg = _('Unknown API version specified')
            msg = gettextutils.translate(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