Ticket #12943: 0001-Return-unnamed-captures-from-sub-URLconfs-if-there-a.patch

File 0001-Return-unnamed-captures-from-sub-URLconfs-if-there-a.patch, 1.4 KB (added by petri.lehtinen@…, 14 years ago)

Return unnamed captures from sub-URLconfs if there are no named captures

  • django/core/urlresolvers.py

    From: Petri Lehtinen <petri.lehtinen@inoi.fi>
    Date: Tue, 23 Feb 2010 16:45:51 +0200
    Subject: [PATCH] Return unnamed captures from sub-URLconfs if there are no named captures.
    
    Partially fixes #12943.
    ---
     django/core/urlresolvers.py |    6 +++++-
     1 files changed, 5 insertions(+), 1 deletions(-)
    
    diff --git a/django/core/urlresolvers.py b/django/core/urlresolvers.py
    index a924afe..43725bf 100644
    a b class RegexURLResolver(object):  
    229229                else:
    230230                    if sub_match:
    231231                        sub_match_dict = dict([(smart_str(k), v) for k, v in match.groupdict().items()])
     232                        if not sub_match_dict:
     233                            sub_match_args = tuple(match.groups() + sub_match[1])
     234                        else:
     235                            sub_match_args = ()
    232236                        sub_match_dict.update(self.default_kwargs)
    233237                        for k, v in sub_match[2].iteritems():
    234238                            sub_match_dict[smart_str(k)] = v
    235                         return sub_match[0], sub_match[1], sub_match_dict
     239                        return sub_match[0], sub_match_args, sub_match_dict
    236240                    tried.append(pattern.regex.pattern)
    237241            raise Resolver404, {'tried': tried, 'path': new_path}
    238242        raise Resolver404, {'path' : path}
Back to Top