예제 #1
0
 def multiview(request):
     for i, match in enumerate(self.matches):
         try:
             return match.func(request, *match.args, **match.kwargs)
         except self.exceptions:
             continue
     raise urlresolvers.Resolver404({'tried': self.patterns_matched, 'path': self.path})
예제 #2
0
    def resolve(self, path):
        tried = []
        matched = []
        patterns_matched = []

        # This is a simplified version of RegexURLResolver. It doesn't
        # support a regex prefix, and it doesn't need to handle include(),
        # so it's simplier, but otherwise this is mostly a copy/paste.
        try:
            for pattern in self.url_patterns:
                sub_match = pattern.resolve(path)
                if sub_match:
                    # Here's the part that's different: instead of returning the
                    # first match, build up a list of all matches.
                    rm = urlresolvers.ResolverMatch(sub_match.func,
                                                    sub_match.args,
                                                    sub_match.kwargs,
                                                    sub_match.url_name)
                    matched.append(rm)
                    patterns_matched.append([pattern])
                tried.append([pattern])
        except urlresolvers.Resolver404 as e:
            pass
        if matched:
            return MultiResolverMatch(matched, self._exceptions,
                                      patterns_matched, path)
        raise urlresolvers.Resolver404({'tried': tried, 'path': path})
예제 #3
0
 def multiview(request):
     for i, match in enumerate(self.matches):
         try:
             response = match.func(request, *match.args, **match.kwargs)
             if type(response) == HttpResponseNotAllowed:
                 continue
             return response
         except self.exceptions:
             continue
     raise urlresolvers.Resolver404({
         'tried': self.patterns_matched,
         'path': self.path
     })
예제 #4
0
        def multiview(request, *args, **kwargs):
            for i, match in enumerate(self.matches):
                try:
                    largs = list(args)
                    largs.extend(list(match.args))
                    match.args = tuple(largs)

                    match.kwargs.update(kwargs)
                    return match.func(request, *match.args, **match.kwargs)
                except self.exceptions:
                    continue
            raise urlresolvers.Resolver404({
                'tried': self.patterns_matched,
                'path': self.path
            })