Fixed another case of reverse URL resolving that wasn't working.
This is a similar situation to that fixed in r9087. We weren't merging multiple levels of include() calls together correctly. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9099 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
ba59295068
commit
37ee86b7ee
|
@ -158,12 +158,12 @@ class RegexURLResolver(object):
|
|||
p_pattern = p_pattern[1:]
|
||||
if isinstance(pattern, RegexURLResolver):
|
||||
parent = normalize(pattern.regex.pattern)
|
||||
for name, (matches, pat) in pattern.reverse_dict.iteritems():
|
||||
new_matches = []
|
||||
for piece, p_args in parent:
|
||||
new_matches.extend([(piece + suffix, p_args + args)
|
||||
for (suffix, args) in matches])
|
||||
self._reverse_dict.appendlist(name, (new_matches, p_pattern + pat))
|
||||
for name in pattern.reverse_dict:
|
||||
for matches, pat in pattern.reverse_dict.getlist(name):
|
||||
new_matches = []
|
||||
for piece, p_args in parent:
|
||||
new_matches.extend([(piece + suffix, p_args + args) for (suffix, args) in matches])
|
||||
self._reverse_dict.appendlist(name, (new_matches, p_pattern + pat))
|
||||
else:
|
||||
bits = normalize(p_pattern)
|
||||
self._reverse_dict.appendlist(pattern.callback, (bits, p_pattern))
|
||||
|
|
|
@ -8,4 +8,6 @@ from views import empty_view
|
|||
urlpatterns = patterns('',
|
||||
url(r'^e-places/(\d+)/$', empty_view, name='extra-places'),
|
||||
url(r'^e-people/(?P<name>\w+)/$', empty_view, name="extra-people"),
|
||||
url('', include('regressiontests.urlpatterns_reverse.included_urls2')),
|
||||
url(r'^prefix/(?P<prefix>\w+)/', include('regressiontests.urlpatterns_reverse.included_urls2')),
|
||||
)
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
"""
|
||||
These URL patterns are included in two different ways in the main urls.py, with
|
||||
an extra argument present in one case. Thus, there are two different ways for
|
||||
each name to resolve and Django must distinguish the possibilities based on the
|
||||
argument list.
|
||||
"""
|
||||
|
||||
from django.conf.urls.defaults import *
|
||||
from views import empty_view
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^part/(?P<value>\w+)/$', empty_view, name="part"),
|
||||
url(r'^part2/(?:(?P<value>\w+)/)?$', empty_view, name="part2"),
|
||||
)
|
|
@ -65,6 +65,12 @@ test_data = (
|
|||
('extra-places', '/e-places/10/', ['10'], {}),
|
||||
('extra-people', '/e-people/fred/', ['fred'], {}),
|
||||
('extra-people', '/e-people/fred/', [], {'name': 'fred'}),
|
||||
('part', '/part/one/', [], {'value': 'one'}),
|
||||
('part', '/prefix/xx/part/one/', [], {'value': 'one', 'prefix': 'xx'}),
|
||||
('part2', '/part2/one/', [], {'value': 'one'}),
|
||||
('part2', '/part2/', [], {}),
|
||||
('part2', '/prefix/xx/part2/one/', [], {'value': 'one', 'prefix': 'xx'}),
|
||||
('part2', '/prefix/xx/part2/', [], {'prefix': 'xx'}),
|
||||
|
||||
# Regression for #9038
|
||||
# These views are resolved by method name. Each method is deployed twice -
|
||||
|
|
Loading…
Reference in New Issue