Don't catch AttributeError during cls init

if obj = cls() do have an attribute error inside it's initialization, it will appears as if the module could not be find.

which is hard to troubleshoot, when the module is really there :)
This commit is contained in:
Bruno Clermont 2012-09-05 14:29:05 +03:00
parent a8917a7a87
commit 8b78278921

View file

@ -62,11 +62,15 @@ class SettingsLoader(object):
mod = imp.load_module(fullname, *self.location)
try:
cls = getattr(mod, self.name)
obj = cls()
except AttributeError: # pragma: no cover
raise ImproperlyConfigured("Couldn't find settings '%s' in "
"module '%s'" %
(self.name, mod.__package__))
try:
obj = cls()
except Exception, err:
raise ImproperlyConfigured("Couldn't load settings '%s.%s': %s" %
(mod.__name__, self.name, err))
for name, value in uppercase_attributes(obj).items():
if callable(value):
value = value()