django.conf.settings now fails loudly if DJANGO_SETTINGS_MODULE is broken in any way.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@105 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
b4168db4af
commit
f69ce6c2b3
|
@ -20,10 +20,15 @@ for setting in dir(global_settings):
|
|||
|
||||
# try to load DJANGO_SETTINGS_MODULE
|
||||
try:
|
||||
mod = __import__(os.environ['DJANGO_SETTINGS_MODULE'], '', '', [''])
|
||||
except (KeyError, ImportError, ValueError):
|
||||
pass
|
||||
else:
|
||||
me.SETTINGS_MODULE = os.environ["DJANGO_SETTINGS_MODULE"]
|
||||
except KeyError:
|
||||
raise EnvironmentError("Environemnt variable DJANGO_SETTINGS_MODULE is undefined."
|
||||
|
||||
try:
|
||||
mod = __import__(me.SETTINGS_MODULE, '', '', [''])
|
||||
except ImportError, e:
|
||||
raise EnvironmentError("Could not import DJANGO_SETTINGS_MODULE '%s' (is it on sys.path?): %s" % (me.SETTINGS_MODULE, e)
|
||||
|
||||
for setting in dir(mod):
|
||||
if setting == setting.upper():
|
||||
setattr(me, setting, getattr(mod, setting))
|
||||
|
|
Loading…
Reference in New Issue