~ubuntu-branches/ubuntu/oneiric/python-django/oneiric

« back to all changes in this revision

Viewing changes to django/db/backends/oracle/creation.py

  • Committer: Bazaar Package Importer
  • Author(s): Jamie Strandboge
  • Date: 2011-02-17 13:34:07 UTC
  • mfrom: (1.1.13 upstream) (4.4.12 sid)
  • Revision ID: james.westby@ubuntu.com-20110217133407-rwr88elhhq6j7ba0
Tags: 1.2.5-1ubuntu1
* Merge from Debian for security fixes (LP: #719031). Remaining changes:
  - debian/control: don't Build-Depends on locales-all, which doesn't exist
    in natty
* Drop the following patches, now included upstream:
  - debian/patches/07_security_admin_infoleak.diff
  - debian/patches/08_security_pasword_reset_dos.diff

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import sys, time
2
 
from django.core import management
3
2
from django.db.backends.creation import BaseDatabaseCreation
4
3
 
5
4
TEST_DATABASE_PREFIX = 'test_'
39
38
        'URLField':                     'VARCHAR2(%(max_length)s)',
40
39
    }
41
40
 
42
 
    remember = {}
 
41
    def __init__(self, connection):
 
42
        self.remember = {}
 
43
        super(DatabaseCreation, self).__init__(connection)
43
44
 
44
45
    def _create_test_db(self, verbosity=1, autoclobber=False):
45
46
        TEST_NAME = self._test_database_name()
113
114
 
114
115
        return self.connection.settings_dict['NAME']
115
116
 
 
117
    def test_db_signature(self):
 
118
        settings_dict = self.connection.settings_dict
 
119
        return (
 
120
            settings_dict['HOST'],
 
121
            settings_dict['PORT'],
 
122
            settings_dict['ENGINE'],
 
123
            settings_dict['NAME'],
 
124
            settings_dict['TEST_USER'],
 
125
        )
 
126
 
116
127
    def _destroy_test_db(self, test_database_name, verbosity=1):
117
128
        """
118
129
        Destroy a test database, prompting the user for confirmation if the
135
146
            'tblspace_temp': TEST_TBLSPACE_TMP,
136
147
        }
137
148
 
138
 
        self.remember['user'] = self.connection.settings_dict['USER']
139
 
        self.remember['passwd'] = self.connection.settings_dict['PASSWORD']
140
 
 
141
149
        cursor = self.connection.cursor()
142
150
        time.sleep(1) # To avoid "database is being accessed by other users" errors.
143
151
        if self._test_user_create():
156
164
        statements = [
157
165
            """CREATE TABLESPACE %(tblspace)s
158
166
               DATAFILE '%(tblspace)s.dbf' SIZE 20M
159
 
               REUSE AUTOEXTEND ON NEXT 10M MAXSIZE 100M
 
167
               REUSE AUTOEXTEND ON NEXT 10M MAXSIZE 200M
160
168
            """,
161
169
            """CREATE TEMPORARY TABLESPACE %(tblspace_temp)s
162
170
               TEMPFILE '%(tblspace_temp)s.dbf' SIZE 20M
214
222
                name = self.connection.settings_dict['TEST_NAME']
215
223
        except AttributeError:
216
224
            pass
217
 
        except:
218
 
            raise
219
225
        return name
220
226
 
221
227
    def _test_database_create(self):
222
 
        name = True
223
 
        try:
224
 
            if self.connection.settings_dict['TEST_CREATE']:
225
 
                name = True
226
 
            else:
227
 
                name = False
228
 
        except KeyError:
229
 
            pass
230
 
        except:
231
 
            raise
232
 
        return name
 
228
        return self.connection.settings_dict.get('TEST_CREATE', True)
233
229
 
234
230
    def _test_user_create(self):
235
 
        name = True
236
 
        try:
237
 
            if self.connection.settings_dict['TEST_USER_CREATE']:
238
 
                name = True
239
 
            else:
240
 
                name = False
241
 
        except KeyError:
242
 
            pass
243
 
        except:
244
 
            raise
245
 
        return name
 
231
        return self.connection.settings_dict.get('TEST_USER_CREATE', True)
246
232
 
247
233
    def _test_database_user(self):
248
234
        name = TEST_DATABASE_PREFIX + self.connection.settings_dict['USER']
251
237
                name = self.connection.settings_dict['TEST_USER']
252
238
        except KeyError:
253
239
            pass
254
 
        except:
255
 
            raise
256
240
        return name
257
241
 
258
242
    def _test_database_passwd(self):
262
246
                name = self.connection.settings_dict['TEST_PASSWD']
263
247
        except KeyError:
264
248
            pass
265
 
        except:
266
 
            raise
267
249
        return name
268
250
 
269
251
    def _test_database_tblspace(self):
273
255
                name = self.connection.settings_dict['TEST_TBLSPACE']
274
256
        except KeyError:
275
257
            pass
276
 
        except:
277
 
            raise
278
258
        return name
279
259
 
280
260
    def _test_database_tblspace_tmp(self):
284
264
                name = self.connection.settings_dict['TEST_TBLSPACE_TMP']
285
265
        except KeyError:
286
266
            pass
287
 
        except:
288
 
            raise
289
267
        return name