Hi,
I got a problem using @exception_handler together with Cheetah.
Consider a situation:
# in cheetah1/controllers.py
from turbogears import controllers, expose, exception_handler
class Root(controllers.RootController):
def get_data(self):
raise ValueError('Error!')
return dict(a=1)
def error(self, tg_exceptions=None):
return dict(exception=str(tg_exceptions))
@exception_handler(error, rules="True")
@expose(template="cheetah:cheetah1.templates.site")
def index(self):
data = self.get_data()
return data
# in cheetah1/templates/site.tmpl
a: $a
I expect @exception_handler to handle the ValueError exception before @expose
renders the template. But it looks like @expose is called before
@exception_handler and Cheetah.Template.NotFound raises. In this situation I
have to handle the exception in the method body and change the template
dynamicaly:
@expose(template="cheetah:cheetah1.templates.site")
def index(self):
try:
data = self.get_data()
except ValueError, error:
return (dict(tg_template='cheetah:cheetah1.templates.error',
error=error))
return data
But @exception_handler is not used and I lose all the benefits it gives! Is it
posible to solve this problem without writing custom template
plugin/decorator/whatever?
Thanks in advance,
--
Timur Izhbulatov
OILspace, 26 Leninskaya sloboda, bld. 2, 2nd floor, 115280 Moscow, Russia
P:+7 495 105 7245 + ext.205 F:+7 495 105 7246 E:[EMAIL PROTECTED]
Building Successful Supply Chains - One Solution At A Time.
www.oilspace.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---