diff options
| author | Barry Warsaw | 2007-08-01 16:11:08 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2007-08-01 16:11:08 -0400 |
| commit | f8a6c46455a409125dcc0fcace7d7116898b0319 (patch) | |
| tree | 4d1c942d92e4b63eb8f000e25477079c14bb5346 /Mailman/database/__init__.py | |
| parent | d72336c1e5932158f6e1f80e5ea9e90d264b7c52 (diff) | |
| parent | 7a7826e112a1d3f1999cb7a11e6df98cfcb712c9 (diff) | |
| download | mailman-f8a6c46455a409125dcc0fcace7d7116898b0319.tar.gz mailman-f8a6c46455a409125dcc0fcace7d7116898b0319.tar.zst mailman-f8a6c46455a409125dcc0fcace7d7116898b0319.zip | |
Move the pending database into the SQLAlchemy/Elixir layer. The old
Pending.py module is removed. Added an interface to this functionality such
that any IPendable (essentially a key/value mapping) can be associated with a
token, and that token can be confirmed and has a lifetime. Any keys and
values can be stored, as long as both are unicodes.
Added a doctest.
Modified initialization of the database layer to support pluggability via
setuptools. No longer is this layer initialized from a module, but now it's
instantiated from a class that implements IDatabase. The StockDatabase class
implements the SQLAchemy/Elixir layer, but this can be overridden in a
setup.py. Bye bye MANAGERS_INIT_FUNCTION, we hardly knew ye.
Added a package Mailman.app which will contain certain application specific
functionality. Right now, the only there there is an IRegistar
implementation, which didn't seem to fit anywhere else.
Speaking of which, the IRegistrar interface implements all the logic related
to registration and verification of email addresses. Think the equivalent of
MailList.AddMember() except generalized out of a mailing list context. This
latter will eventually go away. The IRegistrar sends the confirmation email.
Added an IDomain interface, though the only implementation of this so far
lives in the registration.txt doctest. This defines the context necessary for
domain-level things, like address confirmation.
A bunch of other cleanups in modules that are necessary due to the refactoring
of Pending, but don't affect anything that's actually tested yet, so I won't
vouch for them (except that they don't throw errors on import!).
Clean up Defaults.py; also turn the functions seconds(), minutes(), hours()
and days() into their datetime.timedelta equivalents.
Consolidated the bogus email address exceptions.
In some places where appropriate, use email 4.0 module names instead of the
older brand.
Switch from Mailman.Utils.unique_message_id() to email.utils.make_msgid()
everywhere. This is because we need to allow sending not in the context of a
mailing list (i.e. domain-wide address confirmation message). So we can't use
a Message-ID generator that requires a mailing list. OTOH, this breaks
Message-ID collision detection in the mail->news gateway. I'll fix that
eventually.
Remove the 'verified' row on the Address table. Now verification is checked
by Address.verified_on not being None.
Diffstat (limited to 'Mailman/database/__init__.py')
| -rw-r--r-- | Mailman/database/__init__.py | 62 |
1 files changed, 43 insertions, 19 deletions
diff --git a/Mailman/database/__init__.py b/Mailman/database/__init__.py index 11afe5f3e..e27ad8cf1 100644 --- a/Mailman/database/__init__.py +++ b/Mailman/database/__init__.py @@ -17,35 +17,59 @@ from __future__ import with_statement +__metaclass__ = type +__all__ = [ + 'StockDatabase', + 'flush', # for test convenience + ] + import os from elixir import objectstore +from zope.interface import implements +from Mailman.interfaces import IDatabase, IPending from Mailman.database.listmanager import ListManager from Mailman.database.usermanager import UserManager from Mailman.database.messagestore import MessageStore +from Mailman.database.model import Pendings -__all__ = [ - 'initialize', - 'flush', - ] +# Test suite convenience. +flush = None -def initialize(): - from Mailman.LockFile import LockFile - from Mailman.configuration import config - from Mailman.database import model - # Serialize this so we don't get multiple processes trying to create the - # database at the same time. - lockfile = os.path.join(config.LOCK_DIR, '<dbcreatelock>') - with LockFile(lockfile): - model.initialize() - config.list_manager = ListManager() - config.user_manager = UserManager() - config.message_store = MessageStore() - flush() +class StockDatabase: + implements(IDatabase) + + def __init__(self): + # Expose the flush() method for test case convenience using the stock + # database. + global flush + flush = self.flush + self.list_manager = None + self.user_manager = None + self.message_store = None + + def initialize(self): + from Mailman.LockFile import LockFile + from Mailman.configuration import config + from Mailman.database import model + # Serialize this so we don't get multiple processes trying to create the + # database at the same time. + lockfile = os.path.join(config.LOCK_DIR, '<dbcreatelock>') + with LockFile(lockfile): + model.initialize() + self.list_manager = ListManager() + self.user_manager = UserManager() + self.message_store = MessageStore() + self.flush() + def flush(self): + objectstore.flush() -def flush(): - objectstore.flush() + def __conform__(self, protocol): + if protocol is IPending: + return Pendings() + # Let the rest of the adaptation machinery take a crack at it. + return None |
