Skip to content

Commit 91ef620

Browse files
author
Justus Pendleton
committed
per-tracker 404 templating
Currently if CGI can't map a name it raises NotFound which gets propagated up to roundup-server which generates a plain vanilla 404 page. This changes it so that the CGI client tries to handle NotFound itself by rendering the appropriate template: classname.404.html (or _generic.404.html if no class specific one is found). If the URL can't be mapped to a DB class then we just reraise NotFound and let the upper layer take care of it. Also, add some basic templates for it. They aren't pretty but no worse than what you got before and provide a jumping off point for further customization. This should fix [SF#403287].
1 parent 481af5b commit 91ef620

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

roundup/cgi/client.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: client.py,v 1.235 2007-09-11 21:30:14 jpend Exp $
1+
# $Id: client.py,v 1.236 2007-09-12 01:15:07 jpend Exp $
22

33
"""WWW request handler (also used in the stand-alone server).
44
"""
@@ -323,9 +323,17 @@ def inner_main(self):
323323
self.template = ''
324324
self.error_message.append(message)
325325
self.write_html(self.renderContext())
326-
except NotFound:
327-
# pass through
328-
raise
326+
except NotFound, e:
327+
self.response_code = 404
328+
self.template = '404'
329+
try:
330+
cl = self.db.getclass(self.classname)
331+
self.write_html(self.renderContext())
332+
except KeyError:
333+
# we can't map the URL to a class we know about
334+
# reraise the NotFound and let roundup_server
335+
# handle it
336+
raise NotFound, e
329337
except FormError, e:
330338
self.error_message.append(self._('Form Error: ') + str(e))
331339
self.write_html(self.renderContext())
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<html>
2+
<head>
3+
<title>Item Not Found</title>
4+
</head>
5+
6+
<body>
7+
There is no <span tal:content="context/_classname" /> with id <span tal:content="context/id"/>
8+
</body>
9+
</html>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<html>
2+
<head>
3+
<title>Item Not Found</title>
4+
</head>
5+
6+
<body>
7+
There is no <span tal:content="context/_classname" /> with id <span tal:content="context/id"/>
8+
</body>
9+
</html>

0 commit comments

Comments
 (0)