On Sun, Mar 23, 2008 at 7:42 PM, Jonathan Vanasco <[EMAIL PROTECTED]> wrote:
>
>
>
>  On Mar 23, 8:56 pm, "Mike Orr" <[EMAIL PROTECTED]> wrote:
>  > You can check if there's a valid route by getting the routemapper out
>  > of the environ and trying to match it, but that won't tell you whether
>  > the controller and action exist.  You'd have to duplicate Pylons'
>  > dispatching code to do that.  Or you could make a subrequest and see
>  > if it raises an HTTP error, but that's a bit messy and you'd end up
>  > invoking the second page twice if it exists.
>
>  "duplicate Pylons' dispatching code to do that"
>  ugh... sounds like i'm patching pylons...
>
>
>
>  > Why can't you let the second request worry about it?  Just redirect to
>  > /preview/*url assuming it will succeed, and have a catchall route
>  > after the other preview routes that catches invalid /preview/*url and
>  > redirects again to /preview.
>
>  that's why i'm doing now. but it makes me  feel so dirty.

Why? It seems intuitive to me.  The  first request doesn't know what
the URL is but it knows the user shouldn't be going out of the preview
section.

The really proper way is to call url_for and have it  return a valid
URL.  That assumes you've set specific routes to all valid locations,
which you should normally do anyway, although it gets difficult if one
action handles a large subtree.  If it returns None, the URL is
invalid so you call url_for("preview") instead.

-- 
Mike Orr <[EMAIL PROTECTED]>

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

Reply via email to