Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[1.2.X] Fixed some Oracle backend test DB creation code bugs.
Made saving of modified settings compatible with multi-db, removed dead and superfluous code.

Backport of [14489] from trunk

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@14490 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
ramiro committed Nov 7, 2010
1 parent 7509bdf commit 1431bcc
Showing 1 changed file with 5 additions and 37 deletions.
42 changes: 5 additions & 37 deletions django/db/backends/oracle/creation.py
@@ -1,5 +1,4 @@
import sys, time import sys, time
from django.core import management
from django.db.backends.creation import BaseDatabaseCreation from django.db.backends.creation import BaseDatabaseCreation


TEST_DATABASE_PREFIX = 'test_' TEST_DATABASE_PREFIX = 'test_'
Expand Down Expand Up @@ -39,7 +38,9 @@ class DatabaseCreation(BaseDatabaseCreation):
'URLField': 'VARCHAR2(%(max_length)s)', 'URLField': 'VARCHAR2(%(max_length)s)',
} }


remember = {} def __init__(self, connection):
self.remember = {}
super(DatabaseCreation, self).__init__(connection)


def _create_test_db(self, verbosity=1, autoclobber=False): def _create_test_db(self, verbosity=1, autoclobber=False):
TEST_NAME = self._test_database_name() TEST_NAME = self._test_database_name()
Expand Down Expand Up @@ -135,9 +136,6 @@ def _destroy_test_db(self, test_database_name, verbosity=1):
'tblspace_temp': TEST_TBLSPACE_TMP, 'tblspace_temp': TEST_TBLSPACE_TMP,
} }


self.remember['user'] = self.connection.settings_dict['USER']
self.remember['passwd'] = self.connection.settings_dict['PASSWORD']

cursor = self.connection.cursor() cursor = self.connection.cursor()
time.sleep(1) # To avoid "database is being accessed by other users" errors. time.sleep(1) # To avoid "database is being accessed by other users" errors.
if self._test_user_create(): if self._test_user_create():
Expand Down Expand Up @@ -214,35 +212,13 @@ def _test_database_name(self):
name = self.connection.settings_dict['TEST_NAME'] name = self.connection.settings_dict['TEST_NAME']
except AttributeError: except AttributeError:
pass pass
except:
raise
return name return name


def _test_database_create(self): def _test_database_create(self):
name = True return self.connection.settings_dict.get('TEST_CREATE', True)
try:
if self.connection.settings_dict['TEST_CREATE']:
name = True
else:
name = False
except KeyError:
pass
except:
raise
return name


def _test_user_create(self): def _test_user_create(self):
name = True return self.connection.settings_dict.get('TEST_USER_CREATE', True)
try:
if self.connection.settings_dict['TEST_USER_CREATE']:
name = True
else:
name = False
except KeyError:
pass
except:
raise
return name


def _test_database_user(self): def _test_database_user(self):
name = TEST_DATABASE_PREFIX + self.connection.settings_dict['USER'] name = TEST_DATABASE_PREFIX + self.connection.settings_dict['USER']
Expand All @@ -251,8 +227,6 @@ def _test_database_user(self):
name = self.connection.settings_dict['TEST_USER'] name = self.connection.settings_dict['TEST_USER']
except KeyError: except KeyError:
pass pass
except:
raise
return name return name


def _test_database_passwd(self): def _test_database_passwd(self):
Expand All @@ -262,8 +236,6 @@ def _test_database_passwd(self):
name = self.connection.settings_dict['TEST_PASSWD'] name = self.connection.settings_dict['TEST_PASSWD']
except KeyError: except KeyError:
pass pass
except:
raise
return name return name


def _test_database_tblspace(self): def _test_database_tblspace(self):
Expand All @@ -273,8 +245,6 @@ def _test_database_tblspace(self):
name = self.connection.settings_dict['TEST_TBLSPACE'] name = self.connection.settings_dict['TEST_TBLSPACE']
except KeyError: except KeyError:
pass pass
except:
raise
return name return name


def _test_database_tblspace_tmp(self): def _test_database_tblspace_tmp(self):
Expand All @@ -284,6 +254,4 @@ def _test_database_tblspace_tmp(self):
name = self.connection.settings_dict['TEST_TBLSPACE_TMP'] name = self.connection.settings_dict['TEST_TBLSPACE_TMP']
except KeyError: except KeyError:
pass pass
except:
raise
return name return name

0 comments on commit 1431bcc

Please sign in to comment.