Commits

Anonymous committed 3e08aa8

Added a Paste Deploy entry point for paste.errordocument (not tested, bad me)

Comments (0)

Files changed (2)

paste/errordocument.py

         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
                     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
       openid = paste.auth.open_id:make_open_id_middleware [openid]
       recorder = paste.debug.recorder.record:make_recorder
       pony = paste.pony:make_pony
+      errordocument = paste.errordocument:make_errordocument
 
       [paste.server_runner]
       http = paste.httpserver:server_runner
       """,
       )
+
+