small improvement in db.utils.ConnectionRouter.__init__
Raising an ImproperlyConfigured
error if a configured Router class throws an AttributeError
is confusing. Here's a patch:
diff -r 48bc10d49321 django/db/utils.py
--- a/django/db/utils.py Fri Sep 10 12:25:58 2010 +0200
+++ b/django/db/utils.py Sun Oct 03 13:58:35 2010 +0200
@@ -111,9 +111,11 @@
except ImportError, e:
raise ImproperlyConfigured('Error importing database router %s: "%s"' % (klass_name, e))
try:
- router = getattr(module, klass_name)()
+ router = getattr(module, klass_name)
except AttributeError:
raise ImproperlyConfigured('Module "%s" does not define a database router name "%s"' % (module, klass_name))
+ else:
+ router = router()
else:
router = r
self.routers.append(router)
Turned it into a diff.