Logo Search packages:      
Sourcecode: paste version File versions  Download package

paste::urlparser::URLParser Class Reference

List of all members.


Detailed Description

WSGI middleware

Application dispatching, based on URL.  An instance of `URLParser` is
an application that loads and delegates to other applications.  It
looks for files in its directory that match the first part of
PATH_INFO; these may have an extension, but are not required to have
one, in which case the available files are searched to find the
appropriate file.  If it is ambiguous, a 404 is returned and an error
logged.

By default there is a constructor for .py files that loads the module,
and looks for an attribute ``application``, which is a ready
application object, or an attribute that matches the module name,
which is a factory for building applications, and is called with no
arguments.

URLParser will also look in __init__.py for special overrides.
These overrides are:

``urlparser_hook(environ)``
    This can modified the environment.  Its return value is ignored,
    and it cannot be used to change the response in any way.  You
    *can* use this, for example, to manipulate SCRIPT_NAME/PATH_INFO
    (try to keep them consistent with the original URL -- but
    consuming PATH_INFO and moving that to SCRIPT_NAME is ok).

``urlparser_wrap(environ, start_response, app)``:
    After URLParser finds the application, it calls this function
    (if present).  If this function doesn't call
    ``app(environ, start_response)`` then the application won't be
    called at all!  This can be used to allocate resources (with
    ``try:finally:``) or otherwise filter the output of the
    application.

``not_found_hook(environ, start_response)``:
    If no file can be found (*in this directory*) to match the
    request, then this WSGI application will be called.  You can
    use this to change the URL and pass the request back to
    URLParser again, or on to some other application.  This
    doesn't catch all ``404 Not Found`` responses, just missing
    files.

``application(environ, start_response)``:
    This basically overrides URLParser completely, and the given
    application is used for all requests.  ``urlparser_wrap`` and
    ``urlparser_hook`` are still called, but the filesystem isn't
    searched in any way.

Definition at line 25 of file urlparser.py.


Public Member Functions

def __call__
def __init__
def __repr__
def add_slash
def find_application
def find_file
def find_init_module
def get_application
def get_parser
def not_found
def register_constructor

Public Attributes

 base_python_name
 constructors
 directory
 hide_extensions
 ignore_extensions
 index_names

Static Public Attributes

dictionary global_constructors = {}
 init_module = NoDefault
dictionary parsers_by_directory = {}
tuple register_constructor = classmethod(register_constructor)

The documentation for this class was generated from the following file:

Generated by  Doxygen 1.6.0   Back to index