summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2013-08-27 17:37:48 -0400
committerChris McDonough <chrism@plope.com>2013-08-27 17:37:48 -0400
commitece96f658c631cae662d3849b35ee2723c368abe (patch)
treec4fa85541d57fa019620eb2173950f8c709ff98b
parent2607548beba0082cf6256bf556d65e08cec9ee57 (diff)
downloadpyramid-ece96f658c631cae662d3849b35ee2723c368abe.tar.gz
pyramid-ece96f658c631cae662d3849b35ee2723c368abe.tar.bz2
pyramid-ece96f658c631cae662d3849b35ee2723c368abe.zip
- Fix an obscure problem when combining a virtual root with a route with a
``*traverse`` in its pattern. Now the traversal path generated in such a configuration will be correct, instead of an element missing a leading slash.
-rw-r--r--CHANGES.txt5
-rw-r--r--pyramid/tests/test_traversal.py17
-rw-r--r--pyramid/traversal.py2
3 files changed, 23 insertions, 1 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 1eeb0ce7b..0db274a19 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -149,6 +149,11 @@ Features
Bug Fixes
---------
+- Fix an obscure problem when combining a virtual root with a route with a
+ ``*traverse`` in its pattern. Now the traversal path generated in
+ such a configuration will be correct, instead of an element missing
+ a leading slash.
+
- Fixed a Mako renderer bug returning a tuple with a previous defname value
in some circumstances. See https://github.com/Pylons/pyramid/issues/1037
for more information.
diff --git a/pyramid/tests/test_traversal.py b/pyramid/tests/test_traversal.py
index 2e45ae1a9..ba0be7e06 100644
--- a/pyramid/tests/test_traversal.py
+++ b/pyramid/tests/test_traversal.py
@@ -456,6 +456,23 @@ class ResourceTreeTraverserTests(unittest.TestCase):
self.assertEqual(result['virtual_root'], resource)
self.assertEqual(result['virtual_root_path'], ())
+ def test_withroute_and_traverse_and_vroot(self):
+ abc = DummyContext()
+ resource = DummyContext(next=abc)
+ environ = self._getEnviron(HTTP_X_VHM_ROOT='/abc')
+ request = DummyRequest(environ)
+ traverser = self._makeOne(resource)
+ matchdict = {'traverse':text_('/foo/bar')}
+ request.matchdict = matchdict
+ result = traverser(request)
+ self.assertEqual(result['context'], abc)
+ self.assertEqual(result['view_name'], 'foo')
+ self.assertEqual(result['subpath'], ('bar',))
+ self.assertEqual(result['traversed'], ('abc', 'foo'))
+ self.assertEqual(result['root'], resource)
+ self.assertEqual(result['virtual_root'], abc)
+ self.assertEqual(result['virtual_root_path'], ('abc',))
+
class FindInterfaceTests(unittest.TestCase):
def _callFUT(self, context, iface):
from pyramid.traversal import find_interface
diff --git a/pyramid/traversal.py b/pyramid/traversal.py
index ed49d8743..469e77454 100644
--- a/pyramid/traversal.py
+++ b/pyramid/traversal.py
@@ -640,7 +640,7 @@ class ResourceTreeTraverser(object):
# this is a *traverse stararg (not a {traverse})
# routing has already decoded these elements, so we just
# need to join them
- path = slash.join(path) or slash
+ path = '/' + slash.join(path) or slash
subpath = matchdict.get('subpath', ())
if not is_nonstr_iter(subpath):