From 8f3bf659488c1a946af2cb74c7a1fd4179c350de Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Thu, 7 Nov 2013 01:55:07 -0600 Subject: handle static urls generated with a query string --- pyramid/config/views.py | 2 +- pyramid/tests/test_config/test_views.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) 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)] -- cgit v1.2.3