diff options
author | lmr <lmr@592f7852-d20e-0410-864c-8624ca9c26a4> | 2011-06-22 21:38:51 +0000 |
---|---|---|
committer | lmr <lmr@592f7852-d20e-0410-864c-8624ca9c26a4> | 2011-06-22 21:38:51 +0000 |
commit | bbcc4031b0069c2248094b62c0fe2e26356d65ad (patch) | |
tree | 5f184ec4c1b4d02fe77e22733be33280de96c131 | |
parent | 7136ad2e3934d645fd2f19153c19de82eb6d4bd1 (diff) |
database.database_connection: Fix _copy_exceptions
Under the django backend, Django 1.3 does not have OperationalError
and ProgrammingError anymore (as those are specific to the MySQL
backend). So in this case, let's mock OperationalError and
ProgrammingError with DatabaseError, which is the base DB error
on Django.
This commit fixes autotest_lib.scheduler.monitor_db_functional_test
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
git-svn-id: svn://test.kernel.org/autotest/trunk@5438 592f7852-d20e-0410-864c-8624ca9c26a4
-rw-r--r-- | database/database_connection.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/database/database_connection.py b/database/database_connection.py index ca5f491f..53903c9e 100644 --- a/database/database_connection.py +++ b/database/database_connection.py @@ -12,7 +12,15 @@ _GLOBAL_CONFIG_NAMES = { def _copy_exceptions(source, destination): for exception_name in _DB_EXCEPTIONS: - setattr(destination, exception_name, getattr(source, exception_name)) + try: + setattr(destination, exception_name, + getattr(source, exception_name)) + except AttributeError: + # Under the django backend: + # Django 1.3 does not have OperationalError and ProgrammingError. + # Let's just mock these classes with the base DatabaseError. + setattr(destination, exception_name, + getattr(source, 'DatabaseError')) class _GenericBackend(object): @@ -102,7 +110,8 @@ class _SqliteBackend(_GenericBackend): class _DjangoBackend(_GenericBackend): def __init__(self): from django.db import backend, connection, transaction - super(_DjangoBackend, self).__init__(backend.Database) + import django.db as django_db + super(_DjangoBackend, self).__init__(django_db) self._django_connection = connection self._django_transaction = transaction |