Permalink
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...
malcolmt committed Jun 24, 2007
1 parent ac64e91 commit 6b88d4abd08b05a24a7ff13f6a51579c48118747
Showing with 15 additions and 9 deletions.
  1. +15 −9 django/core/urlresolvers.py
@@ -156,8 +156,10 @@ def _get_callback(self):
try: try:
self._callback = get_callable(self._callback_str) self._callback = get_callable(self._callback_str)
except ImportError, e: except ImportError, e:
mod_name, _ = get_mod_func(self._callback_str)
raise ViewDoesNotExist, "Could not import %s. Error was: %s" % (mod_name, str(e)) raise ViewDoesNotExist, "Could not import %s. Error was: %s" % (mod_name, str(e))
except AttributeError, 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)) raise ViewDoesNotExist, "Tried %s in module %s. Error was: %s" % (func_name, mod_name, str(e))
return self._callback return self._callback
callback = property(_get_callback) callback = property(_get_callback)
@@ -183,15 +185,19 @@ def __init__(self, regex, urlconf_name, default_kwargs=None):
self.urlconf_name = urlconf_name self.urlconf_name = urlconf_name
self.callback = None self.callback = None
self.default_kwargs = default_kwargs or {} self.default_kwargs = default_kwargs or {}
self.reverse_dict = {} self._reverse_dict = {}
for pattern in reversed(self.urlconf_module.urlpatterns): def _get_reverse_dict(self):
if isinstance(pattern, RegexURLResolver): if not self._reverse_dict:
for key, value in pattern.reverse_dict.iteritems(): for pattern in reversed(self.urlconf_module.urlpatterns):
self.reverse_dict[key] = (pattern,) + value if isinstance(pattern, RegexURLResolver):
else: for key, value in pattern.reverse_dict.iteritems():
self.reverse_dict[pattern.callback] = (pattern,) self._reverse_dict[key] = (pattern,) + value
self.reverse_dict[pattern.name] = (pattern,) 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): def resolve(self, path):
tried = [] tried = []

0 comments on commit 6b88d4a

Please sign in to comment.