summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBarry Warsaw2014-09-23 08:58:38 -0400
committerBarry Warsaw2014-09-23 08:58:38 -0400
commit67315dbbeb781921c7eb530b996e1020ad84e91b (patch)
tree2073a29a58c83290a0a82158f0b0f97e76a7cf96 /src
parent31aebefadf7853a4e7767ea1552720f52e06bb7a (diff)
downloadmailman-67315dbbeb781921c7eb530b996e1020ad84e91b.tar.gz
mailman-67315dbbeb781921c7eb530b996e1020ad84e91b.tar.zst
mailman-67315dbbeb781921c7eb530b996e1020ad84e91b.zip
Diffstat (limited to 'src')
-rw-r--r--src/mailman/config/configure.zcml20
-rw-r--r--src/mailman/database/base.py38
-rw-r--r--src/mailman/database/factory.py26
-rw-r--r--src/mailman/database/postgresql.py2
-rw-r--r--src/mailman/database/sqlite.py2
-rw-r--r--src/mailman/interfaces/database.py6
6 files changed, 4 insertions, 90 deletions
diff --git a/src/mailman/config/configure.zcml b/src/mailman/config/configure.zcml
index f9b9cb093..24061f0f0 100644
--- a/src/mailman/config/configure.zcml
+++ b/src/mailman/config/configure.zcml
@@ -40,20 +40,6 @@
factory="mailman.model.requests.ListRequests"
/>
- <adapter
- for="mailman.interfaces.database.IDatabase"
- provides="mailman.interfaces.database.ITemporaryDatabase"
- factory="mailman.database.sqlite.make_temporary"
- name="sqlite"
- />
-
- <adapter
- for="mailman.interfaces.database.IDatabase"
- provides="mailman.interfaces.database.ITemporaryDatabase"
- factory="mailman.database.postgresql.make_temporary"
- name="postgres"
- />
-
<utility
provides="mailman.interfaces.bounce.IBounceProcessor"
factory="mailman.model.bounce.BounceProcessor"
@@ -72,12 +58,6 @@
/>
<utility
- provides="mailman.interfaces.database.IDatabaseFactory"
- factory="mailman.database.factory.DatabaseTemporaryFactory"
- name="temporary"
- />
-
- <utility
provides="mailman.interfaces.domain.IDomainManager"
factory="mailman.model.domain.DomainManager"
/>
diff --git a/src/mailman/database/base.py b/src/mailman/database/base.py
index c4b04b329..f67a60035 100644
--- a/src/mailman/database/base.py
+++ b/src/mailman/database/base.py
@@ -45,10 +45,6 @@ class SABaseDatabase:
Use this as a base class for your DB-Specific derived classes.
"""
- # Tag used to distinguish the database being used. Override this in base
- # classes.
- TAG = ''
-
def __init__(self):
self.url = None
self.store = None
@@ -103,10 +99,6 @@ class SABaseDatabase:
"""
pass
- # XXX Abhilash removed teh _prepare() method. Is that because SA takes
- # care of this for us? If so, then the comment below must be updated.
- # For reference, the SQLite bug is marked "won't fix".
-
def initialize(self, debug=None):
"""See `IDatabase`."""
# Calculate the engine url.
@@ -133,36 +125,6 @@ class SABaseDatabase:
self.store = session()
self.store.commit()
- # XXX We should probably rename load_migrations() and perhaps get rid of
- # load_sql(). The latter is never called any more.
-
- def load_migrations(self, until=None):
- """Load schema migrations.
-
- :param until: Load only the migrations up to the specified timestamp.
- With default value of None, load all migrations.
- :type until: string
- """
- from mailman.database.model import Model
- Model.metadata.create_all(self.engine)
-
- 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 + ';')
-
-
@staticmethod
def _make_temporary():
raise NotImplementedError
diff --git a/src/mailman/database/factory.py b/src/mailman/database/factory.py
index 450672e5b..c06f75031 100644
--- a/src/mailman/database/factory.py
+++ b/src/mailman/database/factory.py
@@ -22,7 +22,6 @@ from __future__ import absolute_import, print_function, unicode_literals
__metaclass__ = type
__all__ = [
'DatabaseFactory',
- 'DatabaseTemporaryFactory',
'DatabaseTestingFactory',
]
@@ -31,13 +30,12 @@ import os
import types
from flufl.lock import Lock
-from zope.component import getAdapter
from zope.interface import implementer
from zope.interface.verify import verifyObject
from mailman.config import config
-from mailman.interfaces.database import (
- IDatabase, IDatabaseFactory, ITemporaryDatabase)
+from mailman.database.model import Model
+from mailman.interfaces.database import IDatabase, IDatabaseFactory
from mailman.utilities.modules import call_name
@@ -54,7 +52,7 @@ class DatabaseFactory:
database = call_name(database_class)
verifyObject(IDatabase, database)
database.initialize()
- database.load_migrations()
+ Model.metadata.create_all(database.engine)
database.commit()
return database
@@ -82,24 +80,8 @@ class DatabaseTestingFactory:
database = call_name(database_class)
verifyObject(IDatabase, database)
database.initialize()
- database.load_migrations()
+ Model.metadata.create_all(database.engine)
database.commit()
# Make _reset() a bound method of the database instance.
database._reset = types.MethodType(_reset, database)
return database
-
-
-
-@implementer(IDatabaseFactory)
-class DatabaseTemporaryFactory:
- """Create a temporary database for some of the migration tests."""
-
- @staticmethod
- def create():
- """See `IDatabaseFactory`."""
- database_class_name = config.database['class']
- database = call_name(database_class_name)
- verifyObject(IDatabase, database)
- adapted_database = getAdapter(
- database, ITemporaryDatabase, database.TAG)
- return adapted_database
diff --git a/src/mailman/database/postgresql.py b/src/mailman/database/postgresql.py
index 1ee454074..bdc3c930c 100644
--- a/src/mailman/database/postgresql.py
+++ b/src/mailman/database/postgresql.py
@@ -40,8 +40,6 @@ from mailman.testing.helpers import configuration
class PostgreSQLDatabase(SABaseDatabase):
"""Database class for PostgreSQL."""
- TAG = 'postgres'
-
def _database_exists(self, store):
"""See `BaseDatabase`."""
table_query = ('SELECT table_name FROM information_schema.tables '
diff --git a/src/mailman/database/sqlite.py b/src/mailman/database/sqlite.py
index b70e474cc..495f69990 100644
--- a/src/mailman/database/sqlite.py
+++ b/src/mailman/database/sqlite.py
@@ -42,8 +42,6 @@ from mailman.testing.helpers import configuration
class SQLiteDatabase(SABaseDatabase):
"""Database class for SQLite."""
- TAG = 'sqlite'
-
def _database_exists(self, store):
"""See `BaseDatabase`."""
table_query = 'select tbl_name from sqlite_master;'
diff --git a/src/mailman/interfaces/database.py b/src/mailman/interfaces/database.py
index c2997ba6b..bd436ed13 100644
--- a/src/mailman/interfaces/database.py
+++ b/src/mailman/interfaces/database.py
@@ -24,7 +24,6 @@ __all__ = [
'DatabaseError',
'IDatabase',
'IDatabaseFactory',
- 'ITemporaryDatabase',
]
@@ -65,11 +64,6 @@ class IDatabase(Interface):
-class ITemporaryDatabase(Interface):
- """Marker interface for test suite adaptation."""
-
-
-
class IDatabaseFactory(Interface):
"Interface for creating new databases."""