Django

Code

Changeset 1376

Show
Ignore:
Timestamp:
11/23/05 15:44:48 (2 years ago)
Author:
adrian
Message:

Added better error handling for trailing periods in URLconf include()s

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/core/urlresolvers.py

    r719 r1376  
    88""" 
    99 
    10 from django.core.exceptions import Http404, ViewDoesNotExist 
     10from django.core.exceptions import Http404, ImproperlyConfigured, ViewDoesNotExist 
    1111import re 
    1212 
     
    7575            return self._urlconf_module 
    7676        except AttributeError: 
    77             self._urlconf_module = __import__(self.urlconf_name, '', '', ['']) 
     77            try: 
     78                self._urlconf_module = __import__(self.urlconf_name, '', '', ['']) 
     79            except ValueError, e: 
     80                # Invalid urlconf_name, such as "foo.bar." (note trailing period) 
     81                raise ImproperlyConfigured, "Error while importing URLconf %r: %s" % (self.urlconf_name, e) 
    7882            return self._urlconf_module 
    7983    urlconf_module = property(_get_urlconf_module)