diff options
Diffstat (limited to 'repoze')
| -rw-r--r-- | repoze/bfg/tests/test_urldispatch.py | 10 | ||||
| -rw-r--r-- | repoze/bfg/urldispatch.py | 5 |
2 files changed, 13 insertions, 2 deletions
diff --git a/repoze/bfg/tests/test_urldispatch.py b/repoze/bfg/tests/test_urldispatch.py index c1fa66aa7..69bd3d971 100644 --- a/repoze/bfg/tests/test_urldispatch.py +++ b/repoze/bfg/tests/test_urldispatch.py @@ -108,6 +108,16 @@ class RoutesMapperTests(unittest.TestCase): self.assertEqual(result['match']['action'], 'action1') self.assertEqual(result['match']['article'], 'article1') + def test_custom_predicate_gets_info(self): + mapper = self._makeOne() + def pred(info, request): + self.assertEqual(info['match'], {'action':u'action1'}) + self.assertEqual(info['route'], mapper.routes['foo']) + return True + mapper.connect('archives/:action/article1', 'foo', predicates=[pred]) + request = self._getRequest(PATH_INFO='/archives/action1/article1') + mapper(request) + def test_cc_bug(self): # "unordered" as reported in IRC by author of # http://labs.creativecommons.org/2010/01/13/cc-engine-and-web-non-frameworks/ diff --git a/repoze/bfg/urldispatch.py b/repoze/bfg/urldispatch.py index becde3ea2..458f1a7a5 100644 --- a/repoze/bfg/urldispatch.py +++ b/repoze/bfg/urldispatch.py @@ -51,9 +51,10 @@ class RoutesMapper(object): match = route.match(path) if match is not None: preds = route.predicates - if preds and not all((p(None, request) for p in preds)): + info = {'route':route, 'match':match} + if preds and not all((p(info, request) for p in preds)): continue - return {'route':route, 'match':match} + return info return {'route':None, 'match':None} |
