Ticket #18494: propagate_unnamed_groups_to_included_urlconfs2.patch

File propagate_unnamed_groups_to_included_urlconfs2.patch, 2.6 KB (added by stefantalpalaru, 12 years ago)

better fix and test case

  • django/core/urlresolvers.py

    diff --git a/django/core/urlresolvers.py b/django/core/urlresolvers.py
    index 625ec63..d0009cc 100644
    a b class RegexURLResolver(LocaleRegexProvider):  
    309309                    if sub_match:
    310310                        sub_match_dict = dict(match.groupdict(), **self.default_kwargs)
    311311                        sub_match_dict.update(sub_match.kwargs)
    312                         return ResolverMatch(sub_match.func, sub_match.args, sub_match_dict, sub_match.url_name, self.app_name or sub_match.app_name, [self.namespace] + sub_match.namespaces)
     312                        return ResolverMatch(sub_match.func, tuple([g for i, g in enumerate(match.groups()) if i + 1 not in match.re.groupindex.values()]) + sub_match.args, sub_match_dict, sub_match.url_name, self.app_name or sub_match.app_name, [self.namespace] + sub_match.namespaces)
    313313                    tried.append([pattern])
    314314            raise Resolver404({'tried': tried, 'path': new_path})
    315315        raise Resolver404({'path' : path})
  • tests/regressiontests/urlpatterns_reverse/namespace_urls.py

    diff --git a/tests/regressiontests/urlpatterns_reverse/namespace_urls.py b/tests/regressiontests/urlpatterns_reverse/namespace_urls.py
    index fa892a4..a342621 100644
    a b urlpatterns = patterns('regressiontests.urlpatterns_reverse.views',  
    5151
    5252    (r'^included/', include('regressiontests.urlpatterns_reverse.included_namespace_urls')),
    5353    (r'^inc(?P<outer>\d+)/', include('regressiontests.urlpatterns_reverse.included_urls', namespace='inc-ns5')),
     54    (r'^inc(?P<outer>\d+)and(\d+)/', include('regressiontests.urlpatterns_reverse.included_urls', namespace='inc-ns5')),
    5455
    5556    (r'^ns-outer/(?P<outer>\d+)/', include('regressiontests.urlpatterns_reverse.included_namespace_urls', namespace='inc-outer')),
    5657
  • tests/regressiontests/urlpatterns_reverse/tests.py

    diff --git a/tests/regressiontests/urlpatterns_reverse/tests.py b/tests/regressiontests/urlpatterns_reverse/tests.py
    index bb25806..f5f85a5 100644
    a b resolve_test_data = (  
    5252    # Namespaces capturing variables
    5353    ('/inc70/', 'inner-nothing', None, 'inc-ns5', views.empty_view, tuple(), {'outer': '70'}),
    5454    ('/inc78/extra/foobar/', 'inner-extra', None, 'inc-ns5', views.empty_view, tuple(), {'outer':'78', 'extra':'foobar'}),
     55    # issue #18494
     56    ('/inc79and80/extra/foobar/', 'inner-extra', None, 'inc-ns5', views.empty_view, ('80',), {'outer':'79', 'extra':'foobar'}),
    5557)
    5658
    5759test_data = (
Back to Top