diff options
author | ianb <devnull@localhost> | 2006-07-14 16:21:57 +0000 |
---|---|---|
committer | ianb <devnull@localhost> | 2006-07-14 16:21:57 +0000 |
commit | 9acb7d24a7aad19a01c3f03cfb9ea9716b322bdb (patch) | |
tree | e737c1bf92201b8c52f00d0873a83f56570446da /paste/errordocument.py | |
parent | 7fd70897412fc58192742a4b1eac2d047fdfec96 (diff) | |
download | paste-9acb7d24a7aad19a01c3f03cfb9ea9716b322bdb.tar.gz |
Added a Paste Deploy entry point for paste.errordocument (not tested, bad me)
Diffstat (limited to 'paste/errordocument.py')
-rw-r--r-- | paste/errordocument.py | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/paste/errordocument.py b/paste/errordocument.py index 20e4b0c..991ba8a 100644 --- a/paste/errordocument.py +++ b/paste/errordocument.py @@ -99,7 +99,7 @@ def forward(app, codes): else: return None return _StatusBasedRedirect(app, error_codes_mapper, codes=codes) - + def custom_forward(app, mapper, global_conf=None, **kw): """ Intercepts a response with a particular status code and returns the @@ -305,3 +305,25 @@ class _StatusBasedRedirect: return app_iter else: return app_iter + +def make_errordocument(app, global_conf, **kw): + """ + Paste Deploy entry point to create a error document wrapper. + Use like:: + + [filter-app:main] + use = egg:Paste#errordocument + next = real-app + 500 = /lib/msg/500.html + 404 = /lib/msg/404.html + + """ + map = {} + for status, redir_loc in kw.items(): + try: + status = int(status) + except ValueError: + raise ValueError('Bad status code: %r' % status) + map[status] = redir_loc + forwarder = forward(app, map) + return forwarder |