Fixed #12693 -- Improved error handling when there is an error setting up the database router chain. Thanks to dhageman for the report and fix.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12305 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
c8873bbba7
commit
c6ee1f6f24
|
@ -92,9 +92,14 @@ class ConnectionRouter(object):
|
||||||
self.routers = []
|
self.routers = []
|
||||||
for r in routers:
|
for r in routers:
|
||||||
if isinstance(r, basestring):
|
if isinstance(r, basestring):
|
||||||
module_name, klass_name = r.rsplit('.', 1)
|
try:
|
||||||
module = import_module(module_name)
|
module_name, klass_name = r.rsplit('.', 1)
|
||||||
router = getattr(module, klass_name)()
|
module = import_module(module_name)
|
||||||
|
router = getattr(module, klass_name)()
|
||||||
|
except ImportError, e:
|
||||||
|
raise ImproperlyConfigured('Error importing database router %s: "%s"' % (klass_name, e))
|
||||||
|
except AttributeError:
|
||||||
|
raise ImproperlyConfigured('Module "%s" does not define a "%s" database router' % (module, klass_name))
|
||||||
else:
|
else:
|
||||||
router = r
|
router = r
|
||||||
self.routers.append(router)
|
self.routers.append(router)
|
||||||
|
|
Loading…
Reference in New Issue