Skip to content

Commit

Permalink
add a default handler for 404 requests
Browse files Browse the repository at this point in the history
  • Loading branch information
kakwa committed Jul 6, 2016
1 parent 1b7473d commit c64bb11
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ldapcherry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def _load_templates(self, config):
)
# load each template
self.temp = {}
for t in ('index.tmpl', 'error.tmpl', 'login.tmpl',
for t in ('index.tmpl', 'error.tmpl', 'login.tmpl', '404.tmpl',
'searchadmin.tmpl', 'searchuser.tmpl', 'adduser.tmpl',
'roles.tmpl', 'groups.tmpl', 'form.tmpl', 'selfmodify.tmpl',
'modify.tmpl', 'service_unavailable.tmpl'
Expand Down Expand Up @@ -1066,6 +1066,17 @@ def modify(self, user=None, **params):
notifications=self._empty_notification(),
)

@cherrypy.expose
@exception_decorator
def default(self, attr=''):
cherrypy.response.status = 404
self._check_auth(must_admin=False)
is_admin = self._check_admin()
return self.temp['404.tmpl'].render(
is_admin=is_admin,
notifications=self._empty_notification(),
)

@cherrypy.expose
@exception_decorator
def selfmodify(self, **params):
Expand Down
7 changes: 7 additions & 0 deletions resources/templates/404.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## -*- coding: utf-8 -*-
<%inherit file="navbar.tmpl"/>
<%block name="core">
<div class="alert alert-warning alert-dismissible" role="alert">
<strong>404 Page not found,</strong> URL not available
</div>
</%block>

0 comments on commit c64bb11

Please sign in to comment.