Exemplo n.º 1
0
    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}
Exemplo n.º 2
0
    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}
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 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)