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.wsgiapp.
PylonsApp
(config=None, **kwargs)¶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
altering the environ['pylons.environ_config']
setting to
indicate what key the session
and cache
functionality
should come from.
Resolving the URL and dispatching can be customized by sub-classing or “monkey-patching” this class. Subclassing is the preferred approach.
__call__
(environ, start_response)¶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:
setup_app_env()
load_test_env()
(Only if operating in
testing mode)resolve()
dispatch()
The response from dispatch()
is expected to be
an iterable (valid PEP 333 WSGI response), which is then
sent back as the response.
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.
find_controller
(controller)¶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.
load_test_env
(environ)¶Sets up our Paste testing environment
register_globals
(environ)¶Registers globals in the environment, called from
setup_app_env()
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.
resolve
(environ, start_response)¶Uses dispatching information found in
environ['wsgiorg.routing_args']
to retrieve a controller
name and return the controller instance from the appropriate
controller module.
Override this to change how the controller name is found and returned.
setup_app_env
(environ, start_response)¶Setup and register all the Pylons objects with the registry
After creating all the global objects for use in the request,
register_globals()
is called to register them
in the environment.