diff options
| author | Chris McDonough <chrism@plope.com> | 2012-03-18 18:09:44 -0400 |
|---|---|---|
| committer | Chris McDonough <chrism@plope.com> | 2012-03-18 18:09:44 -0400 |
| commit | 2b41345e815c2e584fd51bbe534ba35e222f3b80 (patch) | |
| tree | 2953fd7844bebdc6b407d6cbfedd4194724b2fbc | |
| parent | 53c242ee3a05eaf9eef7650611c268546e60ebaf (diff) | |
| download | pyramid-2b41345e815c2e584fd51bbe534ba35e222f3b80.tar.gz pyramid-2b41345e815c2e584fd51bbe534ba35e222f3b80.tar.bz2 pyramid-2b41345e815c2e584fd51bbe534ba35e222f3b80.zip | |
- When ``pyramid.wsgi.wsgiapp2`` calls the downstream WSGI app, the
app's environ will no longer have (deprecated and potentially misleading)
``bfg.routes.matchdict`` or ``bfg.routes.route`` keys in it.
| -rw-r--r-- | CHANGES.txt | 10 | ||||
| -rw-r--r-- | pyramid/request.py | 10 | ||||
| -rw-r--r-- | pyramid/tests/test_request.py | 12 |
3 files changed, 32 insertions, 0 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index f673143cd..d52c8d479 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,13 @@ +Next release +============ + +Bug Fixes +--------- + +- When ``pyramid.wsgi.wsgiapp2`` calls the downstream WSGI app, the + app's environ will no longer have (deprecated and potentially misleading) + ``bfg.routes.matchdict`` or ``bfg.routes.route`` keys in it. + 1.3b3 (2012-03-17) ================== diff --git a/pyramid/request.py b/pyramid/request.py index af1dfee2b..37fac6a46 100644 --- a/pyramid/request.py +++ b/pyramid/request.py @@ -453,4 +453,14 @@ def call_app_with_subpath_as_path_info(request, app): new_request = request.copy() new_request.environ['SCRIPT_NAME'] = new_script_name new_request.environ['PATH_INFO'] = new_path_info + + # In case downstream WSGI app is a Pyramid app, hack around existence of + # these envars until we can safely remove them (see router.py); in any + # case, even if these get removed, it might be better to not copy the + # existing environ but to create a new one instead. + if 'bfg.routes.route' in new_request.environ: + del new_request.environ['bfg.routes.route'] + if 'bfg.routes.matchdict' in new_request.environ: + del new_request.environ['bfg.routes.matchdict'] + return new_request.get_response(app) diff --git a/pyramid/tests/test_request.py b/pyramid/tests/test_request.py index 170ea5c97..6d5131013 100644 --- a/pyramid/tests/test_request.py +++ b/pyramid/tests/test_request.py @@ -546,6 +546,18 @@ class Test_call_app_with_subpath_as_path_info(unittest.TestCase): self.assertEqual(request.environ['SCRIPT_NAME'], '/' + encoded) self.assertEqual(request.environ['PATH_INFO'], '/' + encoded) + def test_it_removes_bfg_routes_info(self): + request = DummyRequest({}) + request.environ['bfg.routes.route'] = True + request.environ['bfg.routes.matchdict'] = True + response = self._callFUT(request, 'app') + self.assertTrue(request.copied) + self.assertEqual(response, 'app') + self.assertEqual(request.environ['SCRIPT_NAME'], '') + self.assertEqual(request.environ['PATH_INFO'], '/') + self.assertFalse('bfg.routes.route' in request.environ) + self.assertFalse('bfg.routes.matchdict' in request.environ) + class DummyRequest: def __init__(self, environ=None): if environ is None: |
