From 6ab71c68f61979891f696d68b124b378e477a76f Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Wed, 26 Jan 2011 01:53:41 -0500 Subject: - ``pyramid.view.append_slash_notfound_view`` now preserves GET query parameters across redirects. --- CHANGES.txt | 3 +++ pyramid/tests/test_view.py | 8 ++++++++ pyramid/view.py | 2 ++ 3 files changed, 13 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index e3f4dc02d..d591a437f 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -8,6 +8,9 @@ Bug Fixes templates for the benefit of folks who cutnpaste and save to a non-UTF8 format. +- ``pyramid.view.append_slash_notfound_view`` now preserves GET query + parameters across redirects. + 1.0b2 (2011-01-24) ================== diff --git a/pyramid/tests/test_view.py b/pyramid/tests/test_view.py index 35925098d..61bf85192 100644 --- a/pyramid/tests/test_view.py +++ b/pyramid/tests/test_view.py @@ -392,6 +392,14 @@ class Test_append_slash_notfound_view(BaseTest, unittest.TestCase): self.assertEqual(response.status, '302 Found') self.assertEqual(response.location, '/abc/') + def test_with_query_string(self): + request = self._makeRequest(PATH_INFO='/abc', QUERY_STRING='a=1&b=2') + context = ExceptionResponse() + self._registerMapper(request.registry, True) + response = self._callFUT(context, request) + self.assertEqual(response.status, '302 Found') + self.assertEqual(response.location, '/abc/?a=1&b=2') + class TestAppendSlashNotFoundViewFactory(BaseTest, unittest.TestCase): def _makeOne(self, notfound_view): from pyramid.view import AppendSlashNotFoundViewFactory diff --git a/pyramid/view.py b/pyramid/view.py index 10a0b7b60..c3ab1d4b1 100644 --- a/pyramid/view.py +++ b/pyramid/view.py @@ -481,6 +481,8 @@ class AppendSlashNotFoundViewFactory(object): slashpath = path + '/' for route in mapper.get_routes(): if route.match(slashpath) is not None: + if request.environ.get('QUERY_STRING'): + slashpath += '?' + request.environ['QUERY_STRING'] return HTTPFound(location=slashpath) return self.notfound_view(context, request) -- cgit v1.2.3