Mercurial > p > roundup > code
diff roundup/cgi/client.py @ 3898:dd00c917fc40
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].
| author | Justus Pendleton <jpend@users.sourceforge.net> |
|---|---|
| date | Wed, 12 Sep 2007 01:15:07 +0000 |
| parents | fca0365521fc |
| children | 182ba3207899 |
line wrap: on
line diff
--- a/roundup/cgi/client.py Tue Sep 11 21:33:30 2007 +0000 +++ b/roundup/cgi/client.py Wed Sep 12 01:15:07 2007 +0000 @@ -1,4 +1,4 @@ -# $Id: client.py,v 1.235 2007-09-11 21:30:14 jpend Exp $ +# $Id: client.py,v 1.236 2007-09-12 01:15:07 jpend Exp $ """WWW request handler (also used in the stand-alone server). """ @@ -323,9 +323,17 @@ self.template = '' self.error_message.append(message) self.write_html(self.renderContext()) - except NotFound: - # pass through - raise + except NotFound, e: + self.response_code = 404 + self.template = '404' + try: + cl = self.db.getclass(self.classname) + self.write_html(self.renderContext()) + except KeyError: + # we can't map the URL to a class we know about + # reraise the NotFound and let roundup_server + # handle it + raise NotFound, e except FormError, e: self.error_message.append(self._('Form Error: ') + str(e)) self.write_html(self.renderContext())
