diff options
| author | Barry Warsaw | 2012-07-23 10:40:53 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2012-07-23 10:40:53 -0400 |
| commit | 5598b9eea196e4085aa91aaf8a0cacaffa200355 (patch) | |
| tree | d3685e9c193705ecee93bc573af960daff874e9e /src/mailman/database/base.py | |
| parent | b2e4c6502c5ff4cdf9488be17556a6d39bbbde6b (diff) | |
| download | mailman-5598b9eea196e4085aa91aaf8a0cacaffa200355.tar.gz mailman-5598b9eea196e4085aa91aaf8a0cacaffa200355.tar.zst mailman-5598b9eea196e4085aa91aaf8a0cacaffa200355.zip | |
Diffstat (limited to 'src/mailman/database/base.py')
| -rw-r--r-- | src/mailman/database/base.py | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/src/mailman/database/base.py b/src/mailman/database/base.py index 80c62658e..f674c9a16 100644 --- a/src/mailman/database/base.py +++ b/src/mailman/database/base.py @@ -186,6 +186,22 @@ class StormBaseDatabase: continue upgrade(self, self.store, version, module_path) + def load_sql(self, store, sql): + """Load the given SQL into the store. + + :param store: The Storm store to load the schema into. + :type store: storm.locals.Store` + :param sql: The possibly multi-line SQL to load. + :type sql: string + """ + # Discard all blank and comment lines. + lines = (line for line in sql.splitlines() + if line.strip() != '' and line.strip()[:2] != '--') + sql = NL.join(lines) + for statement in sql.split(';'): + if statement.strip() != '': + store.execute(statement + ';') + def load_schema(self, store, version, filename, module_path): """Load the schema from a file. @@ -206,17 +222,11 @@ class StormBaseDatabase: """ if filename is not None: contents = resource_string('mailman.database.schema', filename) - # Discard all blank and comment lines. - lines = (line for line in contents.splitlines() - if line.strip() != '' and line.strip()[:2] != '--') - sql = NL.join(lines) - for statement in sql.split(';'): - if statement.strip() != '': - store.execute(statement + ';') + self.load_sql(store, contents) # Add a marker that indicates the migration version being applied. store.add(Version(component='schema', version=version)) - # Add a marker so that the module name can be found later. This is - # used by the test suite to reset the database between tests. + # Add a marker so that the module name can be found later. This + # is used by the test suite to reset the database between tests. store.add(Version(component=version, version=module_path)) def _reset(self): @@ -225,3 +235,7 @@ class StormBaseDatabase: self.store.rollback() ModelMeta._reset(self.store) self.store.commit() + + @staticmethod + def _make_temporary(): + raise NotImplementedError |
