Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[1.0.X] Fixed #10472 -- Fixed a race condition in reverse URL resolving.

This only shows up in for reverse() (not forwards resolving), since that
path uses a globally shared resolver object. Based on a patch from
Travis Terry.

Backport of r10037 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10039 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit a02247ff73c14a79b344faaaa865d7d57d755cb1 1 parent fdde600
Malcolm Tredinnick malcolmt authored
Showing with 6 additions and 3 deletions.
  1. +1 −0  AUTHORS
  2. +5 −3 django/core/urlresolvers.py
1  AUTHORS
View
@@ -393,6 +393,7 @@ answer newbie questions, and generally made Django that much better:
Frank Tegtmeyer <fte@fte.to>
Marcel Telka <marcel@telka.sk>
Terry Huang <terryh.tp@gmail.com>
+ Travis Terry <tdterry7@gmail.com>
thebjorn <bp@datakortet.no>
Zach Thompson <zthompson47@gmail.com>
Michael Thornhill
8 django/core/urlresolvers.py
View
@@ -152,6 +152,7 @@ def __repr__(self):
def _get_reverse_dict(self):
if not self._reverse_dict and hasattr(self.urlconf_module, 'urlpatterns'):
+ lookups = MultiValueDict()
for pattern in reversed(self.urlconf_module.urlpatterns):
p_pattern = pattern.regex.pattern
if p_pattern.startswith('^'):
@@ -163,11 +164,12 @@ def _get_reverse_dict(self):
new_matches = []
for piece, p_args in parent:
new_matches.extend([(piece + suffix, p_args + args) for (suffix, args) in matches])
- self._reverse_dict.appendlist(name, (new_matches, p_pattern + pat))
+ lookups.appendlist(name, (new_matches, p_pattern + pat))
else:
bits = normalize(p_pattern)
- self._reverse_dict.appendlist(pattern.callback, (bits, p_pattern))
- self._reverse_dict.appendlist(pattern.name, (bits, p_pattern))
+ lookups.appendlist(pattern.callback, (bits, p_pattern))
+ lookups.appendlist(pattern.name, (bits, p_pattern))
+ self._reverse_dict = lookups
return self._reverse_dict
reverse_dict = property(_get_reverse_dict)
Please sign in to comment.
Something went wrong with that request. Please try again.