#14381 closed (fixed)
small improvement in db.utils.ConnectionRouter.__init__
| Reported by: | dauerbaustelle | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 1.2 |
| Severity: | Keywords: | ||
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
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)
Attachments (1)
Change History (4)
by , 15 years ago
| Attachment: | django-14381.diff added |
|---|
comment:1 by , 15 years ago
| Triage Stage: | Unreviewed → Ready for checkin |
|---|
Looks good. As it's very simple, going to mark as RFC.
comment:2 by , 15 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
comment:3 by , 15 years ago
Note:
See TracTickets
for help on using tickets.
Turned it into a diff.