On Feb 25, 10:49 pm, Simon King <si...@simonking.org.uk> wrote: > Hi, > > I'm using Pyramid 1.0 for a toy project, and I'm confused about the > view lookup process. I've put a complete script showing my problem at > http://pylonshq.com/pasties/45e916782bf3e2896b94ea2e7a0fc13d > > I'm using traversal, and I'd like to be able to ensure trailing > slashes on certain resources. As far as I can tell, > append_slash_notfound_view is only relevant when using URL dispatch, > so instead I'm trying to use view predicates. >
In the end, I've used a decorator to enforce trailing slashes on certain views: from functools import wraps def with_trailing_slash(view): @wraps(view) def wrapper(*args): # Views are either called with (context, request), or just # request. request = args[-1] if not request.path_url.endswith('/'): location = request.path_url + '/' qs = request.environ.get('QUERY_STRING') if qs: location += '?' + qs return exc.HTTPTemporaryRedirect(location=location) return view(*args) return wrapper However, I'd still like to understand why the original attempt didn't work. Thanks, Simon -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To post to this group, send email to pylons-devel@googlegroups.com. To unsubscribe from this group, send email to pylons-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-devel?hl=en.