summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2011-01-26 01:53:41 -0500
committerChris McDonough <chrism@plope.com>2011-01-26 01:53:41 -0500
commit6ab71c68f61979891f696d68b124b378e477a76f (patch)
treee7dbc754ca26fd3bb6be973fee8bf11c5202ab21
parentbd330cfc22555ce0026b92d40091d0745b60e36c (diff)
downloadpyramid-6ab71c68f61979891f696d68b124b378e477a76f.tar.gz
pyramid-6ab71c68f61979891f696d68b124b378e477a76f.tar.bz2
pyramid-6ab71c68f61979891f696d68b124b378e477a76f.zip
- ``pyramid.view.append_slash_notfound_view`` now preserves GET query
parameters across redirects.
-rw-r--r--CHANGES.txt3
-rw-r--r--pyramid/tests/test_view.py8
-rw-r--r--pyramid/view.py2
3 files changed, 13 insertions, 0 deletions
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)