routes.middleware – Routes WSGI Middleware

Routes WSGI Middleware

Module Contents

class routes.middleware.RoutesMiddleware(wsgi_app, mapper, use_method_override=True, path_info=True, singleton=True)

Routing middleware that handles resolving the PATH_INFO in addition to optionally recognizing method overriding.

Note

This module requires webob to be installed. To depend on it, you may list routes[middleware] in your requirements.txt

Create a Route middleware object

Using the use_method_override keyword will require Paste to be installed, and your application should use Paste’s WSGIRequest object as it will properly handle POST issues with wsgi.input should Routes check it.

If path_info is True, then should a route var contain path_info, the SCRIPT_NAME and PATH_INFO will be altered accordingly. This should be used with routes like:

map.connect('blog/*path_info', controller='blog', path_info='')
routes.middleware.is_form_post(environ)

Determine whether the request is a POSTed html form