I think these are interesting hooks, but don't offer a lot in the way
of capabilities.  I think if we were to pass in the controller
instance to these hooks they would be a lot more valuable.

What I would like to be able to do is override a template on a per-
controller-instance basis.  This means I need access to the controller
instance in the before_render and after_render decorators.  I imagine
something like this:

class MyCrazyController(TGController):

    def __init__(self, is_shouting=False):
        self.is_shouting = is_shouting
        self.default_engine = self.index.decoration.engine['text/
html']

    def shouting(self, *args, **kw):
        current_engine = self.index.decoration.engine['text/html']
        self.index.decoration.engine['text/html'] =
['genshi','shouting_template'].extend(current_engine[:2])
        self.default_engine = current_engine

    def default_voice(self, *args, **kw):
        self.index.decoration.engine['text/html'] =
self.default_engine

    @before_render(shouting)
    @after_render(default_voice)
    @expose('genshi:regular_template')
    def index(self, *args, **kw):
        return dict(john_wayne="you got that right, kid")

This should not require a major change to controllers.py, but I wanted
some second opinions before I implement it.

cheers.
-chris


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears Trunk" 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-trunk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to