From da171de0ff280b5a78c8099c48ad731f0380ed3e Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Mon, 30 May 2011 01:19:18 -0500 Subject: Fixed a bug in dispatch matching * at the end of a route. If there was another * in the pattern the check would fail, causing the final wildcard to be ignored. --- pyramid/tests/test_urldispatch.py | 5 +++++ pyramid/urldispatch.py | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pyramid/tests/test_urldispatch.py b/pyramid/tests/test_urldispatch.py index 7df237aeb..3e861eba9 100644 --- a/pyramid/tests/test_urldispatch.py +++ b/pyramid/tests/test_urldispatch.py @@ -366,6 +366,11 @@ class TestCompileRouteMatchFunctional(unittest.TestCase): self.matches('*traverse', '/La%20Pe%C3%B1a/x', {'traverse':(u'La Pe\xf1a', 'x')}) self.matches('/foo/:id.html', '/foo/bar.html', {'id':'bar'}) + self.matches('/{num:[0-9]+}/*traverse', '/555/abc/def', + {'num':'555', 'traverse':('abc', 'def')}) + import pdb; pdb.set_trace() + self.matches('/{num:[0-9]*}/*traverse', '/555/abc/def', + {'num':'555', 'traverse':('abc', 'def')}) def test_generator_functional(self): self.generates('', {}, '/') diff --git a/pyramid/urldispatch.py b/pyramid/urldispatch.py index 43bc7e50f..230b18e54 100644 --- a/pyramid/urldispatch.py +++ b/pyramid/urldispatch.py @@ -77,7 +77,7 @@ class RoutesMapper(object): # stolen from bobo and modified old_route_re = re.compile(r'(\:[a-zA-Z]\w*)') -star_in_brackets = re.compile(r'\{[^\}]*\*\w*[^\}]*\}') +star_at_end = re.compile(r'\*\w*$') # The torturous nature of the regex named ``route_re`` below is due to the # fact that we need to support at least one level of "inner" squigglies @@ -97,9 +97,9 @@ def _compile_route(route): route = '/' + route star = None - - if '*' in route and not star_in_brackets.search(route): + if star_at_end.search(route): route, star = route.rsplit('*', 1) + pat = route_re.split(route) pat.reverse() rpat = [] -- cgit v1.2.3 From b2eb18ff11a691ad9b5909293d58b014fcb5ef43 Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Mon, 30 May 2011 01:57:04 -0500 Subject: Removed a pdb trace. Oops! --- pyramid/tests/test_urldispatch.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyramid/tests/test_urldispatch.py b/pyramid/tests/test_urldispatch.py index 3e861eba9..ec45cb71e 100644 --- a/pyramid/tests/test_urldispatch.py +++ b/pyramid/tests/test_urldispatch.py @@ -368,7 +368,6 @@ class TestCompileRouteMatchFunctional(unittest.TestCase): self.matches('/foo/:id.html', '/foo/bar.html', {'id':'bar'}) self.matches('/{num:[0-9]+}/*traverse', '/555/abc/def', {'num':'555', 'traverse':('abc', 'def')}) - import pdb; pdb.set_trace() self.matches('/{num:[0-9]*}/*traverse', '/555/abc/def', {'num':'555', 'traverse':('abc', 'def')}) -- cgit v1.2.3