From 25cbe149246aba58b5eba4c13dc67260f09d3862 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Fri, 26 Jun 2009 03:39:27 +0000 Subject: - Cause ``:segment`` matches in route paths to put a Unicode-decoded and URL-dequoted value in the matchdict for the value matched. Previously a non-decoded non-URL-dequoted string was placed in the matchdict as the value. - Cause ``*remainder`` matches in route paths to put a *tuple* in the matchdict dictionary in order to be able to present Unicode-decoded and URL-dequoted values for the traversal path. Previously a non-decoded non-URL-dequoted string was placed in the matchdict as the value. --- repoze/bfg/traversal.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'repoze/bfg/traversal.py') diff --git a/repoze/bfg/traversal.py b/repoze/bfg/traversal.py index b79f87d4c..374804df0 100644 --- a/repoze/bfg/traversal.py +++ b/repoze/bfg/traversal.py @@ -368,7 +368,7 @@ def virtual_root(model, request): urlgenerator = getMultiAdapter((model, request), IContextURL) return urlgenerator.virtual_root() -@lru_cache(500) +@lru_cache(1000) def traversal_path(path): """ Given a ``PATH_INFO`` string (slash-separated path segments), return a tuple representing that path which can be used to @@ -493,9 +493,17 @@ class ModelGraphTraverser(object): def __call__(self, environ): if 'bfg.routes.matchdict' in environ: matchdict = environ['bfg.routes.matchdict'] + path = matchdict.get('traverse', '/') - subpath = matchdict.get('subpath', '') - subpath = tuple(filter(None, subpath.split('/'))) + if hasattr(path, '__iter__'): + # this is a *traverse stararg (not a :traverse) + path = '/'.join([quote_path_segment(x) for x in path]) or '/' + + subpath = matchdict.get('subpath', ()) + if not hasattr(subpath, '__iter__'): + # this is not a *subpath stararg (just a :subpath) + subpath = traversal_path(subpath) + else: # this request did not match a Routes route subpath = () -- cgit v1.2.3