pylons.controllers.core – WSGIController Class

The core WSGIController

Module Contents

class pylons.controllers.core.WSGIController

WSGI Controller that follows WSGI spec for calling and return values

The Pylons WSGI Controller handles incoming web requests that are dispatched from the PylonsBaseWSGIApp. These requests result in a new instance of the WSGIController being created, which is then called with the dict options from the Routes match. The standard WSGI response is then returned with start_response called as per the WSGI spec.

Special WSGIController methods you may define:

This method is called before your action is, and should be used for setting up variables/objects, restricting access to other actions, or other tasks which should be executed before the action is called.
This method is called after the action is, unless an unexpected exception was raised. Subclasses of HTTPException (such as those raised by redirect_to and abort) are expected; e.g. __after__ will be called on redirects.

Each action to be called is inspected with _inspect_call() so that it is only passed the arguments in the Routes match dict that it asks for. The arguments passed into the action can be customized by overriding the _get_method_args() function which is expected to return a dict.

In the event that an action is not found to handle the request, the Controller will raise an “Action Not Found” error if in debug mode, otherwise a 404 Not Found error will be returned.

__call__(environ, start_response)

The main call handler that is called to return a response


Handles dispatching the request to the function using Routes


Retrieve the method arguments to use with inspect call

By default, this uses Routes to retrieve the arguments, override this method to customize the arguments your controller actions are called with.

This method should return a dict.


Calls a function with arguments from _get_method_args()

Given a function, inspect_call will inspect the function args and call it with no further keyword args than it asked for.

If the function has been decorated, it is assumed that the decorator preserved the function signature.

_perform_call(func, args)

Hide the traceback for everything above this method