diff options
author | Russell Keith-Magee <russell@keith-magee.com> | 2010-01-27 07:57:18 +0000 |
---|---|---|
committer | Russell Keith-Magee <russell@keith-magee.com> | 2010-01-27 07:57:18 +0000 |
commit | c6ee1f6f242a6fa5336ce7a670cebae72568ef0c (patch) | |
tree | 15b9b1a024b4c1e4ad25515f9494c9f71693a2dc /django/db/utils.py | |
parent | c8873bbba76bc52ab0766f98e8537b2fa66be71c (diff) | |
download | django-c6ee1f6f242a6fa5336ce7a670cebae72568ef0c.tar.gz |
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
Diffstat (limited to 'django/db/utils.py')
-rw-r--r-- | django/db/utils.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/django/db/utils.py b/django/db/utils.py index da34570a76..83e2452546 100644 --- a/django/db/utils.py +++ b/django/db/utils.py @@ -92,9 +92,14 @@ class ConnectionRouter(object): self.routers = [] for r in routers: if isinstance(r, basestring): - module_name, klass_name = r.rsplit('.', 1) - module = import_module(module_name) - router = getattr(module, klass_name)() + try: + module_name, klass_name = r.rsplit('.', 1) + 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: router = r self.routers.append(router) |