diff MoinMoin/web/apps.py @ 4151:30ac757e72de

Added HTTPException catching middleware
author Florian Krupicka <florian.krupicka@googlemail.com>
date Sun, 08 Jun 2008 18:27:07 +0200
parents 78e6deeadc7e
children b84bcea48523
line wrap: on
line diff
--- a/MoinMoin/web/apps.py	Sun Jun 08 12:16:15 2008 +0200
+++ b/MoinMoin/web/apps.py	Sun Jun 08 18:27:07 2008 +0200
@@ -6,9 +6,21 @@
                 2008-2008 MoinMoin:FlorianKrupicka
     @license: GNU GPL, see COPYING for details.
 """
+from werkzeug.exceptions import HTTPException
+
 from MoinMoin.web.request import Request
 from MoinMoin.web.contexts import XMLRPCContext
 
+class HTTPExceptionsMiddleware(object):
+    def __init__(self, app):
+        self.app = app
+
+    def __call__(self, environ, start_response):
+        try:
+            return self.app(environ, start_response)
+        except HTTPException, e:
+            return e(environ, start_response)
+
 class XMLRPCApp(object):
     """ Handles XML-RPC method calls or dispatches to next layer """