diff options
| author | Michael Merickel <michael@merickel.org> | 2011-05-30 01:19:18 -0500 |
|---|---|---|
| committer | Michael Merickel <michael@merickel.org> | 2011-05-30 01:19:18 -0500 |
| commit | da171de0ff280b5a78c8099c48ad731f0380ed3e (patch) | |
| tree | 6e0f4db0830498d8c5c8a94fddd605aea1bf74eb | |
| parent | 58b7d199c559f5008b81e0c46f22f0b8f03f2fa3 (diff) | |
| download | pyramid-da171de0ff280b5a78c8099c48ad731f0380ed3e.tar.gz pyramid-da171de0ff280b5a78c8099c48ad731f0380ed3e.tar.bz2 pyramid-da171de0ff280b5a78c8099c48ad731f0380ed3e.zip | |
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.
| -rw-r--r-- | pyramid/tests/test_urldispatch.py | 5 | ||||
| -rw-r--r-- | 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 = [] |
