Ñò
;V
Lc
@ sÑ d Z d d k Z d d k l Z d d k l Z l Z d d k l Z d d k l Z d „ Z
d e f d „ ƒ YZ d
e f d „ ƒ YZ
d „ Z d
d d d d
g Z d d „ Z d e f d „ ƒ YZ d S( s
Middleware to display error documents for certain status codes
The middleware in this module can be used to intercept responses with
specified status codes and internally forward the request to an appropriate
URL where the content can be displayed to the user as an error document.
iÿÿÿÿN( t urlparse( t ForwardRequestExceptiont RecursiveMiddleware( t
converters( t replace_headerc C s] x8 | D]0 } t | t ƒ p t d t | ƒ ƒ ‚ q q Wd „ } t t | | d | ƒƒ S( sç
Intercepts a response with a particular status code and returns the
content from a specified URL instead.
The arguments are:
``app``
The WSGI application or middleware chain.
``codes``
A dictionary of integer status codes and the URL to be displayed
if the response uses that code.
For example, you might want to create a static file to display a
"File Not Found" message at the URL ``/error404.html`` and then use
``forward`` middleware to catch all 404 status codes and display the page
you created. In this example ``app`` is your exisiting WSGI
applicaiton::
from paste.errordocument import forward
app = forward(app, codes={404:'/error404.html'})
s4 All status codes should be type int. %s is not validc S s! | i | ƒ o | | Sd Sd S( N( t has_keyt None( t codet messaget environt global_conft codes( ( s7 /usr/lib/python2.6/site-packages/paste/errordocument.pyt error_codes_mapper/ s R ( t
isinstancet intt TypeErrort reprR t StatusBasedForward( t appR R R ( ( s7 /usr/lib/python2.6/site-packages/paste/errordocument.pyt forward s t StatusKeeperc B s e Z d „ Z d „ Z RS( c C s( | | _ | | _ | | _ | | _ d S( N( R t statust urlt headers( t selfR R R R ( ( s7 /usr/lib/python2.6/site-packages/paste/errordocument.pyt __init__? s c st d ‡ ‡ f d † } ˆ i i d ƒ } | d | d