Ticket #8809: django8809-urlerror.diff
File django8809-urlerror.diff, 2.4 KB (added by , 14 years ago) |
---|
-
conf/urls/defaults.py
1 from django.conf import settings 1 2 from django.core.urlresolvers import RegexURLPattern, RegexURLResolver 2 3 from django.core.exceptions import ImproperlyConfigured 3 4 … … 25 26 elif isinstance(t, RegexURLPattern): 26 27 t.add_prefix(prefix) 27 28 pattern_list.append(t) 29 if settings.DEBUG: 30 # Load up debug information on pattern-origin 31 import inspect 32 import os.path 33 current_frame = inspect.currentframe() 34 if current_frame: # currentframe not always supported 35 calling_frame = inspect.getouterframes(current_frame)[1] 36 origin = (calling_frame[4], os.path.normpath(calling_frame[1]), calling_frame[2], ) 37 for pattern in pattern_list: 38 pattern._origin = origin 28 39 return pattern_list 29 40 30 41 def url(regex, view, kwargs=None, name=None, prefix=''): -
core/urlresolvers.py
162 162 return self._callback 163 163 try: 164 164 self._callback = get_callable(self._callback_str) 165 except ImportError, e: 166 mod_name, _ = get_mod_func(self._callback_str) 167 raise ViewDoesNotExist("Could not import %s. Error was: %s" % (mod_name, str(e))) 168 except AttributeError, e: 165 except (ImportError, AttributeError), e: 169 166 mod_name, func_name = get_mod_func(self._callback_str) 170 raise ViewDoesNotExist("Tried %s in module %s. Error was: %s" % (func_name, mod_name, str(e))) 167 debug_info = '' 168 if settings.DEBUG and hasattr(self, '_origin'): # extra debug info available 169 debug_info = ' from pattern "%s" at %s:%s' % self._origin 170 if isinstance(e, ImportError): 171 raise ViewDoesNotExist("Could not import %s%s. Error was: %s" % (mod_name, debug_info, str(e))) 172 elif isinstance(e, AttributeError): 173 raise ViewDoesNotExist("Tried %s in module %s%s. Error was: %s" % (func_name, mod_name, debug_info, str(e))) 171 174 return self._callback 172 175 callback = property(_get_callback) 173 176