diff options
| -rw-r--r-- | pyramid/config/views.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/pyramid/config/views.py b/pyramid/config/views.py index 69f68e422..3b768b0e9 100644 --- a/pyramid/config/views.py +++ b/pyramid/config/views.py @@ -36,6 +36,8 @@ from pyramid.interfaces import ( from pyramid import renderers from pyramid.compat import ( + native_, + text_type, string_types, urlparse, url_quote, @@ -44,6 +46,8 @@ from pyramid.compat import ( is_nonstr_iter ) +from pyramid.encode import urlencode + from pyramid.exceptions import ( ConfigurationError, PredicateMismatch, @@ -1902,7 +1906,18 @@ class StaticURLInfo(object): url = urlparse.urlunparse(url_parse( url, scheme=request.environ['wsgi.url_scheme'])) subpath = url_quote(subpath) - return urljoin(url, subpath) + result = urljoin(url, subpath) + if '_query' in kw: + query = kw.pop('_query') + if isinstance(query, text_type): + result += '?' + native_(query) + elif query: + result += '?' + urlencode(query, doseq=True) + if '_anchor' in kw: + anchor = kw.pop('_anchor') + anchor = native_(anchor, 'utf-8') + result += '#' + anchor + return result raise ValueError('No static URL definition matching %s' % path) |
