From f85f1d077a11a4999f2b2a0c8f955fa3e74ea722 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Thu, 26 Apr 2007 11:17:19 +0000 Subject: [PATCH] Fixed #4129 -- Pass any prefix setting into url(...) constructions so that prefixes work with the new syntax and strings for function names. git-svn-id: http://code.djangoproject.com/svn/django/trunk@5086 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/conf/urls/defaults.py | 7 ++++--- django/core/urlresolvers.py | 8 ++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/django/conf/urls/defaults.py b/django/conf/urls/defaults.py index 49bc176ef3..13a74331d6 100644 --- a/django/conf/urls/defaults.py +++ b/django/conf/urls/defaults.py @@ -11,9 +11,10 @@ def patterns(prefix, *args): pattern_list = [] for t in args: if isinstance(t, (list, tuple)): - pattern_list.append(url(prefix=prefix, *t)) - else: - pattern_list.append(t) + t = url(prefix=prefix, *t) + elif isinstance(t, RegexURLPattern): + t.add_prefix(prefix) + pattern_list.append(t) return pattern_list def url(regex, view, kwargs=None, name=None, prefix=''): diff --git a/django/core/urlresolvers.py b/django/core/urlresolvers.py index c4cbccabcf..38b3263da1 100644 --- a/django/core/urlresolvers.py +++ b/django/core/urlresolvers.py @@ -102,6 +102,14 @@ class RegexURLPattern(object): self.default_args = default_args or {} self.name = name + def add_prefix(self, prefix): + """ + Adds the prefix string to a string-based callback. + """ + if not prefix or not hasattr(self, '_callback_str'): + return + self._callback_str = prefix + '.' + self._callback_str + def resolve(self, path): match = self.regex.search(path) if match: