Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #4673 -- Fixed error reporting bug from [5516]. Also changed th…

…e timing

for populating the reverse cache, since that may have been happening too early.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@5520 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 6b88d4abd08b05a24a7ff13f6a51579c48118747 1 parent ac64e91
@malcolmt malcolmt authored
Showing with 15 additions and 9 deletions.
  1. +15 −9 django/core/urlresolvers.py
View
24 django/core/urlresolvers.py
@@ -156,8 +156,10 @@ def _get_callback(self):
try:
self._callback = get_callable(self._callback_str)
except ImportError, e:
+ mod_name, _ = get_mod_func(self._callback_str)
raise ViewDoesNotExist, "Could not import %s. Error was: %s" % (mod_name, str(e))
except AttributeError, e:
+ mod_name, func_name = get_mod_func(self._callback_str)
raise ViewDoesNotExist, "Tried %s in module %s. Error was: %s" % (func_name, mod_name, str(e))
return self._callback
callback = property(_get_callback)
@@ -183,15 +185,19 @@ def __init__(self, regex, urlconf_name, default_kwargs=None):
self.urlconf_name = urlconf_name
self.callback = None
self.default_kwargs = default_kwargs or {}
- self.reverse_dict = {}
-
- for pattern in reversed(self.urlconf_module.urlpatterns):
- if isinstance(pattern, RegexURLResolver):
- for key, value in pattern.reverse_dict.iteritems():
- self.reverse_dict[key] = (pattern,) + value
- else:
- self.reverse_dict[pattern.callback] = (pattern,)
- self.reverse_dict[pattern.name] = (pattern,)
+ self._reverse_dict = {}
+
+ def _get_reverse_dict(self):
+ if not self._reverse_dict:
+ for pattern in reversed(self.urlconf_module.urlpatterns):
+ if isinstance(pattern, RegexURLResolver):
+ for key, value in pattern.reverse_dict.iteritems():
+ self._reverse_dict[key] = (pattern,) + value
+ else:
+ self._reverse_dict[pattern.callback] = (pattern,)
+ self._reverse_dict[pattern.name] = (pattern,)
+ return self._reverse_dict
+ reverse_dict = property(_get_reverse_dict)
def resolve(self, path):
tried = []
Please sign in to comment.
Something went wrong with that request. Please try again.