The keystone.common.wsgi Module

Utility methods for working with WSGI servers.

class keystone.common.wsgi.Application

Bases: keystone.common.wsgi.BaseApplication

assert_admin(context)
class keystone.common.wsgi.BaseApplication

Bases: object

Base WSGI application wrapper. Subclasses need to implement __call__.

classmethod factory(global_config, **local_config)

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

Any local configuration (that is, values under the [app:APPNAME] section of the paste config) will be passed into the __init__ method as kwargs.

A hypothetical configuration would look like:

[app:wadl] latest_version = 1.3 paste.app_factory = nova.api.fancy_api:Wadl.factory

which would result in a call to the Wadl class as

import nova.api.fancy_api fancy_api.Wadl(latest_version=‘1.3’)

You could of course re-implement the factory method in subclasses, but using the kwarg passing it shouldn’t be necessary.

class keystone.common.wsgi.ComposableRouter(mapper=None)

Bases: keystone.common.wsgi.Router

Router that supports use by ComposingRouter.

add_routes(mapper)

Add routes to given mapper.

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

Bases: keystone.common.wsgi.Router

class keystone.common.wsgi.Debug(application)

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)

Iterator that prints the contents of a wrapper string.

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

Bases: keystone.common.wsgi.Router

A router that allows extensions to supplement or overwrite routes.

Expects to be subclassed.

add_routes(mapper)
classmethod factory(global_config, **local_config)

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

Any local configuration (that is, values under the [filter:APPNAME] section of the paste config) will be passed into the __init__ method as kwargs.

A hypothetical configuration would look like:

[filter:analytics] redis_host = 127.0.0.1 paste.filter_factory = nova.api.analytics:Analytics.factory

which would result in a call to the Analytics class as

import nova.api.analytics analytics.Analytics(app_from_paste, redis_host=‘127.0.0.1’)

You could of course re-implement the factory method in subclasses, but using the kwarg passing it shouldn’t be necessary.

class keystone.common.wsgi.Middleware(application)

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, **local_config)

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

Any local configuration (that is, values under the [filter:APPNAME] section of the paste config) will be passed into the __init__ method as kwargs.

A hypothetical configuration would look like:

[filter:analytics] redis_host = 127.0.0.1 paste.filter_factory = nova.api.analytics:Analytics.factory

which would result in a call to the Analytics class as

import nova.api.analytics analytics.Analytics(app_from_paste, redis_host=‘127.0.0.1’)

You could of course re-implement the factory method in subclasses, but using the kwarg passing it shouldn’t be necessary.

process_request(request)

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)

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

class keystone.common.wsgi.Request(environ, charset=None, unicode_errors=None, decode_param_names=None, **kw)

Bases: webob.request.Request

class keystone.common.wsgi.Router(mapper)

Bases: object

WSGI middleware that maps incoming requests to WSGI apps.

class keystone.common.wsgi.Server(application, host=None, port=None, threads=1000)

Bases: object

Server class to manage multiple WSGI sockets and applications.

kill()
set_ssl(certfile, keyfile=None, ca_certs=None, cert_required=True)
start(key=None, backlog=128)

Run a WSGI server with the given application.

wait()

Wait until all servers have completed running.

class keystone.common.wsgi.WritableLogger(logger, level=10)

Bases: object

A thin wrapper that responds to write and logs.

write(msg)
keystone.common.wsgi.render_exception(error)

Forms a WSGI response based on the current error.

keystone.common.wsgi.render_response(body=None, status=None, headers=None)

Forms a WSGI response.

Previous topic

The keystone.common.utils Module

Next topic

The keystone.config Module

This Page