--- a/web/application.py Fri Jan 24 10:04:56 2014 +0100
+++ b/web/application.py Mon Jan 27 16:19:49 2014 +0100
@@ -1,4 +1,4 @@
-# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
@@ -39,7 +39,7 @@
from cubicweb.web import LOGGER, component
from cubicweb.web import (
StatusResponse, DirectResponse, Redirect, NotFound, LogOut,
- RemoteCallFailed, InvalidSession, RequestError)
+ RemoteCallFailed, InvalidSession, RequestError, PublishException)
from cubicweb.web.request import CubicWebRequestBase
@@ -561,7 +561,7 @@
content = self.vreg['views'].main_template(req, template, view=errview)
except Exception:
content = self.vreg['views'].main_template(req, 'error-template')
- if getattr(ex, 'status', None) is not None:
+ if isinstance(ex, PublishException) and ex.status is not None:
req.status_out = ex.status
return content
@@ -574,11 +574,11 @@
def ajax_error_handler(self, req, ex):
req.set_header('content-type', 'application/json')
- status = ex.status
- if status is None:
- status = httplib.INTERNAL_SERVER_ERROR
+ status = httplib.INTERNAL_SERVER_ERROR
+ if isinstance(ex, PublishException) and ex.status is not None:
+ status = ex.status
+ req.status_out = status
json_dumper = getattr(ex, 'dumps', lambda : unicode(ex))
- req.status_out = status
return json_dumper()
# special case handling