Ñò
jž³Kc @ s´ d Z d d k Z d d k Z d d k Z d d k Z y d d k Z Wn e j
o
e Z n Xd d k l Z d d k l
Z
d d k l Z d d k l
Z
d d k l Z d d k l Z d e f d
„ ƒ YZ d d d
g Z d e f d „ ƒ YZ d „ Z e i d e ƒ d „ Z e i d e ƒ d „ Z d „ Z d „ Z e i d e ƒ d e f d „ ƒ YZ e d „ Z d
e f d „ ƒ YZ d d „ Z e e e d „ Z d S( sH
WSGI applications that parse the URL and dispatch to on-disk resources
iÿÿÿÿN( t request( t fileapp( t
import_string( t httpexceptions( t ETAG( t
converterst NoDefaultc B s e Z RS( ( t __name__t
__module__( ( ( s3 /usr/lib/python2.6/site-packages/paste/urlparser.pyR s t URLParsert StaticURLParsert PkgResourcesParserc B sž e Z d Z h Z e Z h Z e e e d d „ Z d „ Z d „ Z
d d „ Z d „ Z d „ Z
d „ Z d „ Z e e ƒ Z d „ Z d
„ Z d „ Z RS(
s
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 modify 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.
c
K sÑ | o d d k } | i d t ƒ n h } t i i d j o | i t i i d ƒ } n | | _ | | _ | t j o | i
d d ƒ } n t i | ƒ | _
| t j o | i
d
d ƒ } n t i | ƒ | _ | t j o | i
d d ƒ } n t i | ƒ | _ | i i ƒ | _ | o | i i | ƒ n x | i ƒ D]‚ \ }
} |
i d ƒ p t d |
| f ƒ ‚ n |
t d ƒ i ƒ } t | t t f ƒ o t i | ƒ } n | | i |