summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Merickel <michael@merickel.org>2013-11-07 01:08:39 -0600
committerMichael Merickel <michael@merickel.org>2013-11-07 01:27:38 -0600
commitcd5ab51eca5ca95c31eaa12192234938bc1435cb (patch)
treed8886bc84f7a11c6583ff769e47bf9297800eaed
parent19d5fe09bb37d3694f63884eb5a95158f4252473 (diff)
downloadpyramid-cd5ab51eca5ca95c31eaa12192234938bc1435cb.tar.gz
pyramid-cd5ab51eca5ca95c31eaa12192234938bc1435cb.tar.bz2
pyramid-cd5ab51eca5ca95c31eaa12192234938bc1435cb.zip
support query string and anchor on external static urls
-rw-r--r--pyramid/config/views.py17
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)