The nova.wsgi Module¶
Utility methods for working with WSGI servers.
-
class
Application¶ Bases:
objectBase 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.factorywhich 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.
-
classmethod
-
class
Debug(application)¶ Bases:
nova.wsgi.MiddlewareHelper 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.
-
static
-
class
Loader(config_path=None)¶ Bases:
objectUsed to load WSGI applications from paste configurations.
-
load_app(name)¶ Return the paste URLMap wrapped WSGI application.
Parameters: name – Name of the application to load. Returns: Paste URLMap object wrapping the requested application. Raises: nova.exception.PasteAppNotFound
-
-
class
Middleware(application)¶ Bases:
nova.wsgi.ApplicationBase 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.factorywhich 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(req)¶ 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(response)¶ Do whatever you’d like to the response.
-
classmethod
-
class
Request(environ, *args, **kwargs)¶ Bases:
webob.request.Request
-
class
Router(mapper)¶ Bases:
objectWSGI middleware that maps incoming requests to WSGI apps.
-
class
Server(name, app, host='0.0.0.0', port=0, pool_size=None, protocol=<class eventlet.wsgi.HttpProtocol>, backlog=128, use_ssl=False, max_url_len=None)¶ Bases:
oslo_service.service.ServiceBaseServer class to manage a WSGI server, serving a WSGI application.
-
default_pool_size= 1000¶
-
reset()¶ Reset server greenpool size to default.
Returns: None
-
start()¶ Start serving a WSGI application.
Returns: None
-
stop()¶ Stop this server.
This is not a very nice action, as currently the method by which a server is stopped is by killing its eventlet.
Returns: None
-
wait()¶ Block, until the server has stopped.
Waits on the server’s eventlet to finish, then returns.
Returns: None
-