summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorKaren Tracey <kmtracey@gmail.com>2010-03-07 20:14:34 +0000
committerKaren Tracey <kmtracey@gmail.com>2010-03-07 20:14:34 +0000
commitb86b38f6189b947a0fa1384daf7098112fa2bbad (patch)
treea2f701756b27415be42b217dff7003f725060f8f /django
parent90e12662b9ad8cfda78dd6a5dc834ebd0c111a75 (diff)
[1.1.X] Fixed #6228: Changed common middleware to respect request-specific urlconf. Thanks trey, skevy, and mikexstudios.
r12704 and r12705 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12706 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/middleware/common.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/django/middleware/common.py b/django/middleware/common.py
index b2c97c6740..309058870a 100644
--- a/django/middleware/common.py
+++ b/django/middleware/common.py
@@ -53,8 +53,9 @@ class CommonMiddleware(object):
# Append a slash if APPEND_SLASH is set and the URL doesn't have a
# trailing slash and there is no pattern for the current path
if settings.APPEND_SLASH and (not old_url[1].endswith('/')):
- if (not _is_valid_path(request.path_info) and
- _is_valid_path("%s/" % request.path_info)):
+ urlconf = getattr(request, 'urlconf', None)
+ if (not _is_valid_path(request.path_info, urlconf) and
+ _is_valid_path("%s/" % request.path_info, urlconf)):
new_url[1] = new_url[1] + '/'
if settings.DEBUG and request.method == 'POST':
raise RuntimeError, (""
@@ -130,7 +131,7 @@ def _is_internal_request(domain, referer):
# Different subdomains are treated as different domains.
return referer is not None and re.match("^https?://%s/" % re.escape(domain), referer)
-def _is_valid_path(path):
+def _is_valid_path(path, urlconf=None):
"""
Returns True if the given path resolves against the default URL resolver,
False otherwise.
@@ -139,7 +140,7 @@ def _is_valid_path(path):
easier, avoiding unnecessarily indented try...except blocks.
"""
try:
- urlresolvers.resolve(path)
+ urlresolvers.resolve(path, urlconf)
return True
except urlresolvers.Resolver404:
return False