diff --git a/intranet/Root.py b/intranet/Root.py
index 4d2acc63..1150aefc 100755
--- a/intranet/Root.py
+++ b/intranet/Root.py
@@ -65,7 +65,7 @@ cherrypy.config.update({'global':{'crans_ldap':crans_ldap()}})
from plugins.domfilter import DOMFilter
from plugins.templatesfilter import TemplatesFilter
from plugins.verifdroitsfilter import VerifDroitsFilter
-
+from crans.mail import quickSend
# ######################################################## #
# SERVER #
# ######################################################## #
@@ -106,9 +106,31 @@ class Intranet:
}
info.exposed = True
+ def send_error_repport(self, **kw):
+ exp = "intranet"
+ dest = cherrypy.config.get("mail.bugreport", "nounous@crans.org")
+ subject = "Rapport de Bug"
+ text = """
+Bonsoir,
+
+Ceci est un rapport de bug envoye depuis l'intranet.
+
+%s
+ """ % "\n".join( [ "%s: %s" % (str(a), str(kw[a])) for a in kw] )
+ quickSend(exp, dest, subject, text)
+ return self.index()
+
+ send_error_repport.exposed = True
+
+ def testErreur(self):
+ raise Exception, "sdlfkjqmsdklj"
+
+ testErreur.exposed = True
+
def test(self):
return cherrypy.request.remote_addr
test.exposed = True
+
def _cp_on_http_error(self, status, message):
if status==403:
cherrypy.response.body = {
@@ -122,6 +144,9 @@ class Intranet:
'values':{'status':status, 'message':message },
'standalone':False,
}
+ elif status==500:
+ from plugins.templatesfilter import TemplatesFilter
+ TemplatesFilter().goWithThisDict({'template':'error', 'values':{'status':status, 'message':message }})
else:
cherrypy._cputil._cp_on_http_error(status, message)
diff --git a/intranet/plugins/templatesfilter.py b/intranet/plugins/templatesfilter.py
index a3003d40..0470dcc4 100644
--- a/intranet/plugins/templatesfilter.py
+++ b/intranet/plugins/templatesfilter.py
@@ -62,22 +62,23 @@ class TemplatesFilter(BaseFilter):
return str(t)
-
+ def goWithThisDict(self, aDict):
+ body = aDict
+ bodyTemplate = self._getBodyTemplate(body)
+ if bodyTemplate:
+ templatevalues = self._getBodyNameSpace(body)
+ t = Template(file=bodyTemplate, searchList=[templatevalues])
+ body['page'] = str(t)
+
+ if not self._isStandaloneBody(body):
+ body = self._useMainTemplate(body)
+ else:
+ body = body["page"]
+ cherrypy.response.body = body
+
def beforeFinalize(self):
body = cherrypy.response.body
if isinstance(body, dict):
- bodyTemplate = self._getBodyTemplate(body)
- if bodyTemplate:
- templatevalues = self._getBodyNameSpace(body)
- t = Template(file=bodyTemplate, searchList=[templatevalues])
- body['page'] = str(t)
-
- if not self._isStandaloneBody(body):
- body = self._useMainTemplate(body)
- else:
- body = body["page"]
-
- cherrypy.response.body = body
-
+ self.goWithThisDict(body)
diff --git a/intranet/templates/error.tmpl b/intranet/templates/error.tmpl
index 928db5d5..ef080209 100644
--- a/intranet/templates/error.tmpl
+++ b/intranet/templates/error.tmpl
@@ -1,24 +1,26 @@