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/urldispatch.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'repoze/bfg/urldispatch.py') diff --git a/repoze/bfg/urldispatch.py b/repoze/bfg/urldispatch.py index 885f0eb98..7a35f76f1 100644 --- a/repoze/bfg/urldispatch.py +++ b/repoze/bfg/urldispatch.py @@ -1,6 +1,9 @@ import re +from urllib import unquote from repoze.bfg.traversal import _url_quote +from repoze.bfg.traversal import traversal_path +from repoze.bfg.traversal import quote_path_segment _marker = object() @@ -89,8 +92,15 @@ def _compile_route(route): m = match(path) if m is None: return m - return dict(item for item in m.groupdict().iteritems() - if item[1] is not None) + d = {} + for k,v in m.groupdict().iteritems(): + if k is not None: + if k == star: + d[k] = traversal_path(v) + else: + d[k] = unquote(v).decode('utf-8') + return d + gen = ''.join(gen) def generator(dict): @@ -98,7 +108,9 @@ def _compile_route(route): for k, v in dict.items(): if isinstance(v, unicode): v = v.encode('utf-8') - if (k!=star): + if k == star and hasattr(v, '__iter__'): + v = '/'.join([quote_path_segment(x) for x in v]) + elif k != star: try: v = _url_quote(v) except TypeError: -- cgit v1.2.3