diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/mailman/database/base.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/mailman/database/base.py b/src/mailman/database/base.py index cbf88a4ff..1577c981d 100644 --- a/src/mailman/database/base.py +++ b/src/mailman/database/base.py @@ -29,6 +29,8 @@ import logging from lazr.config import as_boolean from pkg_resources import resource_listdir, resource_string +from sqlalchemy import create_engine +from sqlalchemy.orm import sessionmaker from storm.cache import GenerationalCache from storm.locals import create_database, Store from zope.interface import implementer @@ -45,6 +47,42 @@ NL = '\n' @implementer(IDatabase) +class SABaseDatabase: + """The database base class for use with SQLAlchemy. + + Use this as a base class for your DB_Specific derived classes. + """ + TAG='' + + def __inti__(self): + self.url = None + self.store = None + + def begin(self): + pass + + def commit(self): + self.store.commit() + + def abort(self): + self.store.rollback() + + def _prepare(self, url): + pass + + def initialize(Self, debug=None): + url = expand(config.database.url, config.paths) + log.debug('Database url: %s', url) + self.url = url + self._prepare(url) + engine = create_engine(url) + Session = sessionmaker(bind=engine) + store = Session() + self.store = session() + store.commit() + + +@implementer(IDatabase) class StormBaseDatabase: """The database base class for use with the Storm ORM. |
