15 messages in com.googlegroups.pylons-discussFwd: Routes user survey
FromSent OnAttachments
Mike Orr23 Nov 2007 01:36 
Marcin Kasperski23 Nov 2007 04:30 
Paweł Stradomski23 Nov 2007 05:46 
Mike Orr23 Nov 2007 05:50 
Mike Orr23 Nov 2007 06:06 
Paweł Stradomski23 Nov 2007 06:18 
Mike Orr23 Nov 2007 07:31 
Paweł Stradomski23 Nov 2007 07:34 
Mike Orr23 Nov 2007 08:37 
Jose Galvez23 Nov 2007 10:34 
Ben Bangert23 Nov 2007 15:34 
Ian Bicking23 Nov 2007 21:56 
Andrew Smart24 Nov 2007 11:04 
Ian Bicking24 Nov 2007 13:59 
Mike Orr26 Nov 2007 16:16 
Subject:Fwd: Routes user survey
From:Mike Orr (slug@public.gmane.org)
Date:11/23/2007 08:37:20 AM
List:com.googlegroups.pylons-discuss

On Nov 23, 2007 7:34 AM, Paweł Stradomski <pstr@gmail.com> wrote:

W liście Mike Orr z dnia piątek 23 listopada 2007:

On Nov 23, 2007 6:19 AM, Paweł Stradomski <pstr@gmail.com> wrote:

Well, I think the current solution (function being passed by the framework to routes) is better, as it gives more flexibility. Throwin an exception would force just a single way of informing the framework about redirects - and is a bad idea, as this propagating exception might cause strange behaviour, like rolling back database sessions.

Hmm. Well, the match function is called in only one place by the framework, so it would be easy to catch it close to the source. And without an exception it would have to have two very different return values: a match dict or a string destination.

But redirect_to might be called by the user.

So redirect_to can stay the same. I would actually prefer that redirect_to would get replaced by "raise Redirect", but it's too established in Pylons apps to change it now.

However, there are a couple ways to make the matching side more to your liking. There are two special cases: status with location (redirect), and status without location (gone, forbidden, future statuses). This could be handled by two special keys in the match dict (_status and _location). If present, the framework should call a special controller to handle them. This would allow the user to customize the response if desired.

Or routes could choose the controller and action itself, either via attributes (the way .sub_domains is handled now), or via ordinary controller/action arguments. The latter would avoid changes to Routes itself but would add boilerplate verbosity to the route definitions.

m.connect(None, "foo/foo", location="http://example.com/bar/bar.html", controller="special", action="redirect", status=303)

At least that would define a standard Pylons way to support redirects/statuses without forcing each user to reinvent it on their own. Perhaps this can be tucked into one of the existing standard controllers somewhere. (The Template controller doesn't do much, for instance.)