Code

Ticket #15180: urlresolvers.diff

File urlresolvers.diff, 1.9 KB (added by olaf, 3 years ago)
Line 
1208c208
2<                         for matches, pat in pattern.reverse_dict.getlist(name):
3---
4>                         for matches, pat, default_args in pattern.reverse_dict.getlist(name):
5212c212
6<                             lookups.appendlist(name, (new_matches, p_pattern + pat))
7---
8>                             lookups.appendlist(name, (new_matches, p_pattern + pat, default_args))
9219c219
10<                 lookups.appendlist(pattern.callback, (bits, p_pattern))
11---
12>                 lookups.appendlist(pattern.callback, (bits, p_pattern, pattern.default_args))
13221c221
14<                     lookups.appendlist(pattern.name, (bits, p_pattern))
15---
16>                     lookups.appendlist(pattern.name, (bits, p_pattern, pattern.default_args))
17312c312
18<         for possibility, pattern in possibilities:
19---
20>         for possibility, pattern, default_args in possibilities:
21319a320,335
22>                     # first check if some of the requested kwargs are defined as an default arg.
23>                     # pop them from the requested kwargs so that they won't interfere with the
24>                     # comparison of the other kwargs. If one of the default_args is requested but
25>                     # differ with its value the corresponding URL will be ignored.
26>                     bak_kwargs = kwargs.copy()
27>                     continue_upper_loop = False
28>                     for key in default_args:
29>                         if key in kwargs:
30>                             tmp = kwargs.pop(key)
31>                             if tmp != default_args[key]:
32>                                 continue_upper_loop = True
33>                                 break
34>                     if continue_upper_loop:
35>                         # we will restore the original kwargs before continuing.
36>                         kwargs=bak_kwargs.copy()
37>                         continue
38323a340
39>                     kwargs = bak_kwargs.copy()