keystone.common.wsgi module

keystone.common.wsgi module

Utility methods for working with WSGI servers.

class keystone.common.wsgi.Application[source]

Bases: keystone.common.wsgi.BaseApplication

assert_admin(request)[source]

Ensure the user is an admin.

Raises:
classmethod base_url(context, endpoint_type=None)[source]
class keystone.common.wsgi.BaseApplication[source]

Bases: object

Base WSGI application wrapper. Subclasses need to implement __call__.

classmethod factory(global_config, **local_config)[source]

Used for loading in middleware (holdover from paste.deploy).

class keystone.common.wsgi.ComposableRouter(mapper=None)[source]

Bases: keystone.common.wsgi.Router

Router that supports use by ComposingRouter.

add_routes(mapper)[source]

Add routes to given mapper.

class keystone.common.wsgi.ComposingRouter(mapper=None, routers=None)[source]

Bases: keystone.common.wsgi.Router

class keystone.common.wsgi.Debug(application, conf=None)[source]

Bases: keystone.common.wsgi.Middleware

Helper class for debugging a WSGI application.

Can be inserted into any WSGI application chain to get information about the request and response.

static print_generator(app_iter)[source]

Iterator that prints the contents of a wrapper string.

class keystone.common.wsgi.ExtensionRouter(application, mapper=None)[source]

Bases: keystone.common.wsgi.Router

A router that allows extensions to supplement or overwrite routes.

Expects to be subclassed.

add_routes(mapper)[source]
classmethod factory(global_config, **local_config)[source]

Used for loading in middleware (holdover from paste.deploy).

class keystone.common.wsgi.Middleware(application, conf=None)[source]

Bases: keystone.common.wsgi.Application

Base WSGI middleware.

These classes require an application to be initialized that will be called next. By default the middleware will simply call its wrapped app, or you can override __call__ to customize its behavior.

classmethod factory(global_config)[source]

Used for paste app factories in paste.deploy config files.

process_request(request)[source]

Called on each request.

If this returns None, the next application down the stack will be executed. If it returns a response then that response will be returned and execution will stop here.

process_response(request, response)[source]

Do whatever you’d like to the response, based on the request.

class keystone.common.wsgi.Router(mapper)[source]

Bases: object

WSGI middleware that maps incoming requests to WSGI apps.

class keystone.common.wsgi.RoutersBase[source]

Bases: object

Base class for Routers.

append_v3_routers(mapper, routers)[source]

Append v3 routers.

Subclasses should override this method to map its routes.

Use self._add_resource() to map routes for a resource.

class keystone.common.wsgi.V3ExtensionRouter(application, mapper=None)[source]

Bases: keystone.common.wsgi.ExtensionRouter, keystone.common.wsgi.RoutersBase

Base class for V3 extension router.

keystone.common.wsgi.best_match_language(req)[source]

Determine the best available locale.

This returns best available locale based on the Accept-Language HTTP header passed in the request.

keystone.common.wsgi.middleware_exceptions(method)[source]
keystone.common.wsgi.render_exception(error, context=None, request=None, user_locale=None)[source]

Form a WSGI response based on the current error.

keystone.common.wsgi.render_response(body=None, status=None, headers=None, method=None)[source]

Form a WSGI response.

Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.