summaryrefslogtreecommitdiff
path: root/django/db/utils.py
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2010-01-29 15:45:55 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2010-01-29 15:45:55 +0000
commit11ee9746a0530ec38f523fb4de44950d9b783877 (patch)
tree7fd170a1d1231b294694b28a796f8b0ad5b70b8f /django/db/utils.py
parent47acb1d659c0c589b6c6532f8618da0bb757324c (diff)
Fixed #12702 -- Introduced a common implementation of DatabaseError and IntegrityError, so that database backends can (re)raise common error classes. Thanks for Waldemar Kornewald for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12352 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/utils.py')
-rw-r--r--django/db/utils.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/django/db/utils.py b/django/db/utils.py
index fe5d7944aa..00b3568cb0 100644
--- a/django/db/utils.py
+++ b/django/db/utils.py
@@ -7,6 +7,16 @@ from django.utils.importlib import import_module
DEFAULT_DB_ALIAS = 'default'
+# Define some exceptions that mirror the PEP249 interface.
+# We will rethrow any backend-specific errors using these
+# common wrappers
+class DatabaseError(Exception):
+ pass
+
+class IntegrityError(DatabaseError):
+ pass
+
+
def load_backend(backend_name):
try:
module = import_module('.base', 'django.db.backends.%s' % backend_name)
@@ -40,9 +50,11 @@ def load_backend(backend_name):
else:
raise # If there's some other error, this must be an error in Django itself.
+
class ConnectionDoesNotExist(Exception):
pass
+
class ConnectionHandler(object):
def __init__(self, databases):
self.databases = databases
@@ -87,6 +99,7 @@ class ConnectionHandler(object):
def all(self):
return [self[alias] for alias in self]
+
class ConnectionRouter(object):
def __init__(self, routers):
self.routers = []