On Thu, Apr 9, 2009 at 8:00 AM, Ash <[email protected]> wrote:
>
Hi, This is a topic that has been discussed a lot and there is no
definite conclusion about it.

> I've been fighting with redirect for a while, trying to do things that
> I'm used to being able to do in Django and Catalyst.
>
> The docs on tg.redirect and tg.url are fairly sparse, so I have no
> clue if this should work or not.
>
> But what I have is two controllers, mounted within each other. Most of
> the methods in the second (nested) controller redirect back to the
> index when done making changes. (They are buttons on the index page
> and don't have templates.) But since one controller is within the
> other, I didn't want to hardcode 'redirect(/x/y/)' everwhere, as the
> location of the controllers might change over time. I've tried the
> following options with no luck:
>
> redirect(self.index)   # This would be preferable. If you could
> redirect to an @expose'd method.
> redirect('') # Redirect to the index of this controller?
> redirect() # Alternative version of the same?
> redirect (action='index') # Should work via routes, but errors out.
>
I think you are confusing the use of redirect with url, redirect is
supposed to get a url and send it there, so what you really want will
be
redirect(tg.url(...))

Please see
http://trac.turbogears.org/ticket/2248

> At a very least, there seems to be this bug in tg.url:
>
> if isinstance(args[0], list):
>    args[0] = u'/'.join(args[0])
> if args and isinstance(args[0], basestring):
>    ...
>
> Shouldn't the first line be 'if args and isinstance(args[0], list):'
> so that we can avoid passing an initial non-keyword argument and use
> the routes version of url?

This is for backwards compatibility with TG1 and it is one of the
things that makes this function so complex. See
http://trac.turbogears.org/ticket/2080 for the explanation.


>
>
> >
>

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