def __call__(self, request): environ = request.environ try: # empty if mounted under a path in mod_wsgi, for example path = environ['PATH_INFO'] or '/' except KeyError: path = '/' for route in self.routelist: match = route.match(path) if match is not None: preds = route.predicates info = {'match':match, 'route':route} if preds and not all((p(info, request) for p in preds)): continue return info return {'route':None, 'match':None}
def __call__(self, request): environ = request.environ try: # empty if mounted under a path in mod_wsgi, for example path = environ['PATH_INFO'] or '/' except KeyError: path = '/' for route in self.routelist: match = route.match(path) if match is not None: preds = route.predicates info = {'match': match, 'route': route} if preds and not all((p(info, request) for p in preds)): continue return info return {'route': None, 'match': None}
def test_all(self): from pyramid.compat import all self.assertEqual(all([True, True]), True) self.assertEqual(all([False, False]), False) self.assertEqual(all([False, True]), False)