From: Simo Sorce Date: Tue, 7 Oct 2014 01:48:58 +0000 (-0400) Subject: Add pretty handler for 404 X-Git-Tag: v0.3.0~66 X-Git-Url: http://git.cascardo.info/?p=cascardo%2Fipsilon.git;a=commitdiff_plain;h=907d40cac424c9c7bf3a190b445858bc6eab949e Add pretty handler for 404 Signed-off-by: Simo Sorce Reviewed-by: Patrick Uiterwijk --- diff --git a/ipsilon/root.py b/ipsilon/root.py index 0046ddf..b2654ac 100755 --- a/ipsilon/root.py +++ b/ipsilon/root.py @@ -43,6 +43,7 @@ class Root(Page): # set up error pages cherrypy.config['error_page.400'] = errors.Error_400(self._site) cherrypy.config['error_page.401'] = errors.Error_401(self._site) + cherrypy.config['error_page.404'] = errors.Error_404(self._site) cherrypy.config['error_page.500'] = errors.Errors(self._site) # now set up the default login plugins diff --git a/ipsilon/util/errors.py b/ipsilon/util/errors.py index 3d7ea28..2f3cc3d 100755 --- a/ipsilon/util/errors.py +++ b/ipsilon/util/errors.py @@ -54,3 +54,10 @@ class Error_401(Errors): def handler(self, status, message, traceback, version): return self._error_template('unauthorized.html', title='Unauthorized', message=message) + + +class Error_404(Errors): + + def handler(self, status, message, traceback, version): + return self._error_template('notfound.html', + title='Not Found', message=message) diff --git a/ipsilon/util/page.py b/ipsilon/util/page.py index 1548d47..a99d2f4 100755 --- a/ipsilon/util/page.py +++ b/ipsilon/util/page.py @@ -108,7 +108,7 @@ class Page(Log): return t.render(**m) def default(self, *args, **kwargs): - raise cherrypy.HTTPError(404) + raise cherrypy.NotFound() def add_subtree(self, name, page): self.__dict__[name] = page diff --git a/templates/notfound.html b/templates/notfound.html new file mode 100644 index 0000000..71743b5 --- /dev/null +++ b/templates/notfound.html @@ -0,0 +1,13 @@ +{% extends "master.html" %} +{% block main %} +
+

404 - Not Found

+ {% if message: %} +

{{ message }}

+ {% else %} +

This page does not exist.

+ {% endif %} +

If you think this is an error, contact the server administrator to + resolve the problem.

+
+{% endblock %}