> >> > Sorry for the long subject line, it pretty much says (asks) it all. > >> > > >> > This would be useful in situations where several controller methods > >> > use the same template but the actual appearance differs slightly from > >> > method to method. Is it possible? > >> > >> I imagine it will be tricky, if possible at all. This page has one > >> approach: > >> > >> http://mail.python.org/pipermail/python-list/2003-May/205437.html > >> > >> Why not just be explicit and pass in an additional argument to the > >> template? > > > > Sure, if it can not be done in a clean and nice way that's what I'll > > do, well, that's what I'm currently doing already. The link you sent > > is indeed talking about this issue but is too hackish and doesn't > > qualify for "clean and nice" :) > > how about a decorator, something like: > > def tell_template_this_controller(func): > def _func(*args, **kw): > d = return func(*args, **kw) > d['this_controller'] = func.__name__ > return _func > > > Then use like: > > @expose(template='.templates.whatever') > @tell_template_this_controller > def controller_1(self): > # do stuff > return dict(...) > > > @expose(template='.templates.whatever') > @tell_template_this_controller > def controller_2(self): > # do stuff > return dict(...) > > > > and in the whatever template: > > <p>Hello from the <span py:content="this_controller" /> controller!</p>
Yep, that's what I do currently, slightly different code, but the same idea. Cheers, Daniel --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---

