diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-06-26 03:39:27 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-06-26 03:39:27 +0000 |
| commit | 25cbe149246aba58b5eba4c13dc67260f09d3862 (patch) | |
| tree | e1d3dcc01ef3847d7a39a7c04de8d65da77ab386 /repoze/bfg/urldispatch.py | |
| parent | 1e40cf21f1bb41feee5f377db8b02a06657d2001 (diff) | |
| download | pyramid-25cbe149246aba58b5eba4c13dc67260f09d3862.tar.gz pyramid-25cbe149246aba58b5eba4c13dc67260f09d3862.tar.bz2 pyramid-25cbe149246aba58b5eba4c13dc67260f09d3862.zip | |
- 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.
Diffstat (limited to 'repoze/bfg/urldispatch.py')
| -rw-r--r-- | repoze/bfg/urldispatch.py | 18 |
1 files changed, 15 insertions, 3 deletions
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: |
