Alberto Valverde wrote:
> On Dec 9, 2006, at 4:49 PM, chiangf wrote:
>
> >
> > I tried doing something like (not sure if this is what you meant?):
> > class Controller:
> >     @expose()
> >     def index(self, **kw):
> >          if kw.get('action_kung'):
> >              self.kung(**kw)
> >          elif kw.get('action_foo'):
> >              self.foo(**kw)
> >
> >      @expose(sometemplate1)
> >     def kung(self, **kw):
> >          ...
> >          return dict(kw=kw)
> >
> >      @expose(sometemplate2)
> >     def foo(self, **kw):
> >          ...
> >          return dict(kw=kw)
> >
> >
> > Where I want kung to display sometemplate1 and foo to display
> > sometemplate2.  But if I un the above code, then it calls kung (or
> > foo)
> > and then returns back to index() and continues... is there any way to
> > redirect to kung so that sometemplate1 is displayed?
> >
> > Did that make sense?  I was actually getting lost writing my own
> > question, :)
>
> You need to return the output of the method you're calling:
>
>      @expose()
>      def index(self, **kw):
>           if kw.get('action_kung'):
>               return self.kung(**kw)
> ----------^^^^^
>           elif kw.get('action_foo'):
>               return self.foo(**kw)

Keep in mind that you also need to set a tg_template key in your return
dictionary if you want to override the template that is used. So to
have index use kung's template you would use code like:

    @expose()
    def index(self, **kw):
        if kw.get('action_kung'):
            return
self.kung(**kw).update(dict(tg_template="sometemplate1"))

-Adam

> 
> Alberto


--~--~---------~--~----~------------~-------~--~----~
 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to