ah, excellent. thank you for your tips!

best, andi

On 06.12.2012, at 22:34, Michael Merickel wrote:

> if request.matched_route.name in ['item-list-latest', 'item-list-views']:
>     pass
> 
> This will work great if you're only using URL dispatch. Otherwise you should 
> make a function out of this that does not fail if request.matched_route is 
> None and does something else for traversal based on request.context and 
> request.view_name.
> 
> request.route_url and request.current_route_url are expensive operations in 
> comparison.
> 
> Also request.current_route_url() is way slower than just doing request.url if 
> you just want the current url.
> 
> 
> On Thu, Dec 6, 2012 at 3:04 PM, Andi Balke <[email protected]> wrote:
> hi guys, 
> 
> is there a good solution to match the current url against some routes? or do 
> i have to do something like this? ::
> 
>       167     
> 
> +        if request.current_route_url() == (  
>       168     +                request.route_url('item-list-latest') or  
>       169     +                request.route_url('item-list-views') or  
>       170     +                request.route_url('item-list-nearby') or  
>       171     +                request.route_url('item-list-popular')  
>       172     +            )   or "nearby" in request.current_route_url() or 
> "dashboard" in request.current_route_url() :  
> 
> i imagine something like ``request.match_route('/foo/bar/42')`` that returns 
> the routename or something like that to me. 
> 
> cheers, andi
> 
> 
> -- 
> 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.

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