Commit 37ee86b7 authored by Malcolm Tredinnick's avatar Malcolm Tredinnick
Browse files

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
parent ba592950
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -158,11 +158,11 @@ 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():
                    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])
                                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)
+2 −0
Original line number Diff line number Diff line
@@ -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')),
)
+14 −0
Original line number Diff line number Diff line
"""
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"),
)
+6 −0
Original line number Diff line number Diff line
@@ -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 -