[Twisted-web] handling rendering exceptions: patterns strategy?
Federico Tomassini
federicotom at yahoo.it
Sun Feb 24 10:59:27 EST 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
I'm trying to create a machinery to handle renderer exceptions.
Considere the following template:
<span nevow:render="main_page">
<span nevow:pattern="main_pattern">
...
</span>
<span nevow:pattern="safe_pattern">
<span nevow:render="handle_err">Oops, there was an exception</span>
</span>
</span>
The idea is to define a base class so that, for each page based on such
template, on renderer exceptions, the main pattern is deleted and the
failsafe pattern is filled with a human readable error.
For example:
class basePage(rend.Page):
def render_main_page(self, ctx, d):
try:
render_the_main_pattern(...)
except Exception, err:
self.strexception= str(err)
render_the_safe_pattern(...)
def render_handle_err(self, ctx, d):
if hasattr(self, 'strexception'):
return self.strexception
return 'UfoError'
class OtherPage(basePage):
...
It would be very nice to have such machinery: how can I choose to render
the safe_pattern if and only if the main pattern rendering fails?
Otherwise, is there in your opinion a better strategy?
- --
efphe
Today is Setting Orange, the 55th day of Chaos in the YOLD 3174
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
iD8DBQFHwZRfi7obm7aBjHcRAhpvAJ9eSijml+0OgAgmsMW4PVCPUeuiLQCghSs6
lwaZFMx3tKi/W887lsh9MTY=
=BUEA
-----END PGP SIGNATURE-----
More information about the Twisted-web
mailing list