Fixed #4673 -- Fixed error reporting bug from [5516]. Also changed the 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
This commit is contained in:
Malcolm Tredinnick 2007-06-24 09:38:30 +00:00
parent ac64e91a0c
commit 6b88d4abd0
1 changed files with 14 additions and 8 deletions

View File

@ -156,8 +156,10 @@ class RegexURLPattern(object):
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 @@ class RegexURLResolver(object):
self.urlconf_name = urlconf_name
self.callback = None
self.default_kwargs = default_kwargs or {}
self.reverse_dict = {}
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
self._reverse_dict[key] = (pattern,) + value
else:
self.reverse_dict[pattern.callback] = (pattern,)
self.reverse_dict[pattern.name] = (pattern,)
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 = []