Mercurial > p > roundup > code
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 3897:e2c2d91932ad | 3898:dd00c917fc40 |
|---|---|
| 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 $ |
| 2 | 2 |
| 3 """WWW request handler (also used in the stand-alone server). | 3 """WWW request handler (also used in the stand-alone server). |
| 4 """ | 4 """ |
| 5 __docformat__ = 'restructuredtext' | 5 __docformat__ = 'restructuredtext' |
| 6 | 6 |
| 321 # users may always see the front page | 321 # users may always see the front page |
| 322 self.classname = self.nodeid = None | 322 self.classname = self.nodeid = None |
| 323 self.template = '' | 323 self.template = '' |
| 324 self.error_message.append(message) | 324 self.error_message.append(message) |
| 325 self.write_html(self.renderContext()) | 325 self.write_html(self.renderContext()) |
| 326 except NotFound: | 326 except NotFound, e: |
| 327 # pass through | 327 self.response_code = 404 |
| 328 raise | 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 | |
| 329 except FormError, e: | 337 except FormError, e: |
| 330 self.error_message.append(self._('Form Error: ') + str(e)) | 338 self.error_message.append(self._('Form Error: ') + str(e)) |
| 331 self.write_html(self.renderContext()) | 339 self.write_html(self.renderContext()) |
| 332 except: | 340 except: |
| 333 if self.instance.config.WEB_DEBUG: | 341 if self.instance.config.WEB_DEBUG: |
