summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarry Warsaw2008-03-12 20:34:03 -0400
committerBarry Warsaw2008-03-12 20:34:03 -0400
commit91f84edd80b4470cb0c9dfca30890388af6daec8 (patch)
treee6cd540bfb2f575ce65e41ac2de4b9fc3d0631fe
parent4e2070ca3d8bca288cbc2d96771a78c22a7ec031 (diff)
downloadmailman-91f84edd80b4470cb0c9dfca30890388af6daec8.tar.gz
mailman-91f84edd80b4470cb0c9dfca30890388af6daec8.tar.zst
mailman-91f84edd80b4470cb0c9dfca30890388af6daec8.zip
-rw-r--r--mailman/database/__init__.py17
-rw-r--r--mailman/interfaces/database.py12
-rw-r--r--mailman/tests/test_documentation.py5
3 files changed, 30 insertions, 4 deletions
diff --git a/mailman/database/__init__.py b/mailman/database/__init__.py
index 1615c291f..dabe70c79 100644
--- a/mailman/database/__init__.py
+++ b/mailman/database/__init__.py
@@ -45,6 +45,8 @@ from mailman.interfaces import IDatabase, SchemaVersionMismatchError
class StockDatabase:
+ """The standard database, using Storm on top of SQLite."""
+
implements(IDatabase)
def __init__(self):
@@ -56,6 +58,7 @@ class StockDatabase:
self._store = None
def initialize(self, debug=None):
+ """See `IDatabase`."""
# Serialize this so we don't get multiple processes trying to create
# the database at the same time.
with Lock(os.path.join(config.LOCK_DIR, 'dbcreate.lck')):
@@ -66,6 +69,19 @@ class StockDatabase:
self.pendings = Pendings()
self.requests = Requests()
+ def begin(self):
+ """See `IDatabase`."""
+ # Storm takes care of this for us.
+ pass
+
+ def commit(self):
+ """See `IDatabase`."""
+ self.store.commit()
+
+ def abort(self):
+ """See `IDatabase`."""
+ self.store.rollback()
+
def _create(self, debug):
# Calculate the engine url.
url = Template(config.DEFAULT_DATABASE_URL).safe_substitute(
@@ -119,6 +135,7 @@ class StockDatabase:
self.store = store
def _reset(self):
+ """See `IDatabase`."""
from mailman.database.model import ModelMeta
self.store.rollback()
ModelMeta._reset(self.store)
diff --git a/mailman/interfaces/database.py b/mailman/interfaces/database.py
index 0bacdaa3a..706613ba0 100644
--- a/mailman/interfaces/database.py
+++ b/mailman/interfaces/database.py
@@ -65,10 +65,14 @@ class IDatabase(Interface):
This is only used by the test framework.
"""
- # XXX Eventually we probably need to support a transaction manager
- # interface, e.g. begin(), commit(), abort(). We will probably also need
- # to support a shutdown() method for cleanly disconnecting from the
- # database.sy
+ def begin():
+ """Begin the current transaction."""
+
+ def commit():
+ """Commit the current transaction."""
+
+ def abort():
+ """Abort the current transaction."""
list_manager = Attribute(
"""The IListManager instance provided by the database layer.""")
diff --git a/mailman/tests/test_documentation.py b/mailman/tests/test_documentation.py
index d11d4bd70..9f46e55c8 100644
--- a/mailman/tests/test_documentation.py
+++ b/mailman/tests/test_documentation.py
@@ -53,7 +53,12 @@ def specialized_message_from_string(text):
def setup(testobj):
"""Test setup."""
+ # In general, I don't like adding convenience functions, since I think
+ # doctests should do the imports themselves. It makes for better
+ # documentation that way. However, a few are really useful, or help to
+ # hide some icky test implementation details.
testobj.globs['message_from_string'] = specialized_message_from_string
+ testobj.globs['commit'] = config.db.commit