pylons.wsgiapp– PylonsWSGI App Creator¶
WSGI App Creator
This module is responsible for creating the basic Pylons WSGI application (PylonsApp). It’s generally assumed that it will be called by Paste, though any WSGI server could create and call the WSGI app as well.
Pylons WSGI Application
This basic WSGI app is provided should a web developer want to get access to the most basic Pylons web application environment available. By itself, this Pylons web application does little more than dispatch to a controller and setup the context object, the request object, and the globals object.
Additional functionality like sessions, and caching can be setup by
environ['pylons.environ_config'] setting to
indicate what key the
should come from.
Resolving the URL and dispatching can be customized by sub-classing or “monkey-patching” this class. Subclassing is the preferred approach.
Setup and handle a web request
PylonsApp splits its functionality into several methods to make it easier to subclass and customize core functionality.
The methods are called in the following order:
dispatch(controller, environ, start_response)¶
Dispatches to a controller, will instantiate the controller if necessary.
Override this to change how the controller dispatch is handled.
Locates a controller by attempting to import it then grab the SomeController instance from the imported module.
Controller name is assumed to be a module in the controllers directory unless it contains a ‘.’ or ‘:’ which is then assumed to be a dotted path to the module and name of the controller object.
Override this to change how the controller object is found once the URL has been resolved.
Sets up our Paste testing environment
Registers globals in the environment, called from
Override this to control how the Pylons API is setup. Note that
a custom render function will need to be used if the
pylons.app_globals global is not available.
Uses dispatching information found in
environ['wsgiorg.routing_args'] to retrieve a controller
name and return the controller instance from the appropriate
Override this to change how the controller name is found and returned.