backport oldstable stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 10 May 2011 16:15:43 +0200
branchstable
changeset 7353 73d873681c7c
parent 7351 ed66f236715d (current diff)
parent 7348 dce4fa28ae49 (diff)
child 7354 f627ab500fda
backport oldstable
--- a/web/application.py	Tue May 10 14:07:14 2011 +0200
+++ b/web/application.py	Tue May 10 16:15:43 2011 +0200
@@ -390,7 +390,9 @@
                 raise StatusResponse(404, self.notfound_content(req))
             except ValidationError, ex:
                 self.validation_error_handler(req, ex)
-            except (Unauthorized, BadRQLQuery, RequestError), ex:
+            except Unauthorized, ex:
+                self.error_handler(req, ex, tb=False, code=403)
+            except (BadRQLQuery, RequestError), ex:
                 self.error_handler(req, ex, tb=False)
             except BaseException, ex:
                 self.error_handler(req, ex, tb=True)
@@ -422,7 +424,7 @@
             raise Redirect(req.form['__errorurl'].rsplit('#', 1)[0])
         self.error_handler(req, ex, tb=False)
 
-    def error_handler(self, req, ex, tb=False):
+    def error_handler(self, req, ex, tb=False, code=500):
         excinfo = sys.exc_info()
         self.exception(repr(ex))
         req.set_header('Cache-Control', 'no-cache')
@@ -441,7 +443,7 @@
             content = self.vreg['views'].main_template(req, template, view=errview)
         except:
             content = self.vreg['views'].main_template(req, 'error-template')
-        raise StatusResponse(500, content)
+        raise StatusResponse(code, content)
 
     def need_login_content(self, req):
         return self.vreg['views'].main_template(req, 'login')