summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Merickel <michael@merickel.org>2013-11-07 01:55:07 -0600
committerMichael Merickel <michael@merickel.org>2013-11-07 01:55:07 -0600
commit8f3bf659488c1a946af2cb74c7a1fd4179c350de (patch)
tree22cd65394e9ff7968c5d034005a981d6a84648e8
parentfc30e8e2bac083907f0fcda6fddfd30d0d48751f (diff)
downloadpyramid-8f3bf659488c1a946af2cb74c7a1fd4179c350de.tar.gz
pyramid-8f3bf659488c1a946af2cb74c7a1fd4179c350de.tar.bz2
pyramid-8f3bf659488c1a946af2cb74c7a1fd4179c350de.zip
handle static urls generated with a query string
-rw-r--r--pyramid/config/views.py2
-rw-r--r--pyramid/tests/test_config/test_views.py10
2 files changed, 11 insertions, 1 deletions
diff --git a/pyramid/config/views.py b/pyramid/config/views.py
index 190eefc98..022984420 100644
--- a/pyramid/config/views.py
+++ b/pyramid/config/views.py
@@ -1913,7 +1913,7 @@ class StaticURLInfo(object):
if '_query' in kw:
query = kw.pop('_query')
if isinstance(query, text_type):
- result += '?' + native_(query)
+ result += '?' + quote_plus(query)
elif query:
result += '?' + urlencode(query, doseq=True)
if '_anchor' in kw:
diff --git a/pyramid/tests/test_config/test_views.py b/pyramid/tests/test_config/test_views.py
index a7e32f0c6..832921713 100644
--- a/pyramid/tests/test_config/test_views.py
+++ b/pyramid/tests/test_config/test_views.py
@@ -3820,6 +3820,16 @@ class TestStaticURLInfo(unittest.TestCase):
result = inst.generate('package:path/abc def', request, a=1)
self.assertEqual(result, 'http://example.com/abc%20def')
+ def test_generate_url_with_custom_query(self):
+ inst = self._makeOne()
+ registrations = [('http://example.com/', 'package:path/', None)]
+ inst._get_registrations = lambda *x: registrations
+ request = self._makeRequest()
+ result = inst.generate('package:path/abc def', request, a=1,
+ _query='(openlayers)')
+ self.assertEqual(result,
+ 'http://example.com/abc%20def?%28openlayers%29')
+
def test_generate_url_with_custom_anchor(self):
inst = self._makeOne()
registrations = [('http://example.com/', 'package:path/', None)]