summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Mailman/Defaults.py2
-rw-r--r--Mailman/database/__init__.py40
-rw-r--r--Mailman/database/listmanager.py12
-rw-r--r--Mailman/database/messagestore.py2
-rw-r--r--Mailman/database/model/__init__.py47
-rw-r--r--Mailman/database/model/address.py27
-rw-r--r--Mailman/database/model/language.py8
-rw-r--r--Mailman/database/model/mailinglist.py233
-rw-r--r--Mailman/database/model/mailman.sql206
-rw-r--r--Mailman/database/model/member.py24
-rw-r--r--Mailman/database/model/message.py13
-rw-r--r--Mailman/database/model/pending.py21
-rw-r--r--Mailman/database/model/preferences.py26
-rw-r--r--Mailman/database/model/requests.py22
-rw-r--r--Mailman/database/model/roster.py1
-rw-r--r--Mailman/database/model/user.py18
-rw-r--r--Mailman/database/model/version.py15
-rw-r--r--Mailman/database/types.py60
-rw-r--r--Mailman/database/usermanager.py4
-rw-r--r--Mailman/docs/ack-headers.txt25
-rw-r--r--Mailman/tests/test_documentation.py15
-rw-r--r--setup.py2
22 files changed, 529 insertions, 294 deletions
diff --git a/Mailman/Defaults.py b/Mailman/Defaults.py
index 203fd878b..a5234bdd9 100644
--- a/Mailman/Defaults.py
+++ b/Mailman/Defaults.py
@@ -120,7 +120,7 @@ DEFAULT_VAR_DIRECTORY = '/var/mailman'
# will store their data in this database, although external rosters may access
# other databases in their own way. This string support substitutions using
# any variable in the Configuration object.
-SQLALCHEMY_ENGINE_URL = 'sqlite:///$DATA_DIR/mailman.db'
+DEFAULT_DATABASE_URL = 'sqlite:///$DATA_DIR/mailman.db'
# For debugging purposes
SQLALCHEMY_ECHO = False
diff --git a/Mailman/database/__init__.py b/Mailman/database/__init__.py
index acc74642f..a3a5293af 100644
--- a/Mailman/database/__init__.py
+++ b/Mailman/database/__init__.py
@@ -26,15 +26,13 @@ __all__ = [
import os
from locknix.lockfile import Lock
-from elixir import objectstore
+from storm.properties import PropertyPublisherMeta
from zope.interface import implements
from Mailman.interfaces import IDatabase
from Mailman.database.listmanager import ListManager
from Mailman.database.usermanager import UserManager
from Mailman.database.messagestore import MessageStore
-from Mailman.database.model import Pendings
-from Mailman.database.model import Requests
# Test suite convenience. Application code should use config.db.flush()
# instead.
@@ -55,24 +53,52 @@ class StockDatabase:
self.message_store = None
self.pendings = None
self.requests = None
+ self._store = None
def initialize(self, debug=None):
+ # Avoid circular imports.
from Mailman.configuration import config
from Mailman.database import model
+ from Mailman.database.model import Pendings
+ from Mailman.database.model import Requests
# 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')):
- model.initialize(debug)
+ self.store = model.initialize(debug)
self.list_manager = ListManager()
self.user_manager = UserManager()
self.message_store = MessageStore()
self.pendings = Pendings()
self.requests = Requests()
- self.flush()
def flush(self):
- objectstore.flush()
+ pass
def _reset(self):
- model._reset()
+ for model_class in _class_registry:
+ for row in self.store.find(model_class):
+ self.store.remove(row)
+
+
+_class_registry = set()
+
+
+class ModelMeta(PropertyPublisherMeta):
+ """Do more magic on table classes."""
+
+ def __init__(self, name, bases, dict):
+ # Before we let the base class do it's thing, force an __storm_table__
+ # property to enforce our table naming convention.
+ self.__storm_table__ = name.lower()
+ super(ModelMeta, self).__init__(name, bases, dict)
+ # Register the model class so that it can be more easily cleared.
+ # This is required by the test framework.
+ if name == 'Model':
+ return
+ _class_registry.add(self)
+
+
+class Model(object):
+ """Like Storm's `Storm` subclass, but with a bit extra."""
+ __metaclass__ = ModelMeta
diff --git a/Mailman/database/listmanager.py b/Mailman/database/listmanager.py
index 46f0aa859..1a17cb96e 100644
--- a/Mailman/database/listmanager.py
+++ b/Mailman/database/listmanager.py
@@ -15,17 +15,15 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
-"""SQLAlchemy/Elixir based provider of IListManager."""
+"""A mailing list manager."""
import datetime
-from elixir import *
from zope.interface import implements
from Mailman import Errors
from Mailman.Utils import split_listname, fqdn_listname
from Mailman.configuration import config
-from Mailman.database.model import MailingList, Pendings
from Mailman.interfaces import IListManager
@@ -34,9 +32,13 @@ class ListManager(object):
implements(IListManager)
def create(self, fqdn_listname):
+ # Avoid circular imports.
+ from Mailman.database.model import MailingList
listname, hostname = split_listname(fqdn_listname)
- mlist = MailingList.get_by(list_name=listname,
- host_name=hostname)
+ mlist = config.db.store.find(
+ MailingList,
+ MailingList.list_name == listname,
+ MailingList.host_name == hostname).one()
if mlist:
raise Errors.MMListAlreadyExistsError(fqdn_listname)
mlist = MailingList(fqdn_listname)
diff --git a/Mailman/database/messagestore.py b/Mailman/database/messagestore.py
index e0e6cd9f1..87f2fc828 100644
--- a/Mailman/database/messagestore.py
+++ b/Mailman/database/messagestore.py
@@ -32,7 +32,6 @@ from zope.interface import implements
from Mailman import Utils
from Mailman.configuration import config
-from Mailman.database.model import Message
from Mailman.interfaces import IMessageStore
# It could be very bad if you have already stored files and you change this
@@ -46,6 +45,7 @@ class MessageStore:
implements(IMessageStore)
def add(self, message):
+ from Mailman.database.model import Message
# Ensure that the message has the requisite headers.
message_ids = message.get_all('message-id', [])
if len(message_ids) <> 1:
diff --git a/Mailman/database/model/__init__.py b/Mailman/database/model/__init__.py
index 86f79a84b..c15670403 100644
--- a/Mailman/database/model/__init__.py
+++ b/Mailman/database/model/__init__.py
@@ -15,6 +15,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
+from __future__ import with_statement
+
__all__ = [
'Address',
'Language',
@@ -28,9 +30,9 @@ __all__ = [
import os
import sys
-import elixir
-from sqlalchemy import create_engine
+from storm import database
+from storm.locals import create_database, Store
from string import Template
from urlparse import urlparse
@@ -39,12 +41,6 @@ import Mailman.Version
from Mailman import constants
from Mailman.Errors import SchemaVersionMismatchError
from Mailman.configuration import config
-
-# This /must/ be set before any Elixir classes are defined (i.e. imported).
-# This tells Elixir to use the short table names (i.e. the class name) instead
-# of a mangled full class path.
-elixir.options_defaults['shortnames'] = True
-
from Mailman.database.model.address import Address
from Mailman.database.model.language import Language
from Mailman.database.model.mailinglist import MailingList
@@ -59,8 +55,8 @@ from Mailman.database.model.version import Version
def initialize(debug):
- # Calculate the engine url
- url = Template(config.SQLALCHEMY_ENGINE_URL).safe_substitute(config.paths)
+ # Calculate the engine url.
+ url = Template(config.DEFAULT_DATABASE_URL).safe_substitute(config.paths)
# XXX By design of SQLite, database file creation does not honor
# umask. See their ticket #1193:
# http://www.sqlite.org/cvstrac/tktview?tn=1193,31
@@ -75,21 +71,30 @@ def initialize(debug):
# permissions. We only try to do this for SQLite engines, and yes, we
# could have chmod'd the file after the fact, but half dozen and all...
touch(url)
- engine = create_engine(url)
- engine.echo = (config.SQLALCHEMY_ECHO if debug is None else debug)
- elixir.metadata.bind = engine
- elixir.setup_all()
- elixir.create_all()
+ database = create_database(url)
+ store = Store(database)
+ database.DEBUG = (config.DEFAULT_DATABASE_ECHO if debug is None else debug)
+ # XXX Storm does not currently have schema creation. This is not an ideal
+ # way to handle creating the database, but it's cheap and easy for now.
+ import Mailman.database.model
+ schema_file = os.path.join(
+ os.path.dirname(Mailman.database.model.__file__),
+ 'mailman.sql')
+ with open(schema_file) as fp:
+ sql = fp.read()
+ for statement in sql.split(';'):
+ store.execute(statement + ';')
# Validate schema version.
- v = Version.get_by(component='schema')
+ v = store.find(Version, component=u'schema').one()
if not v:
# Database has not yet been initialized
- v = Version(component='schema',
+ v = Version(component=u'schema',
version=Mailman.Version.DATABASE_SCHEMA_VERSION)
- elixir.session.flush()
+ store.add(v)
elif v.version <> Mailman.Version.DATABASE_SCHEMA_VERSION:
# XXX Update schema
raise SchemaVersionMismatchError(v.version)
+ return store
def touch(url):
@@ -101,9 +106,3 @@ def touch(url):
# Ignore errors
if fd > 0:
os.close(fd)
-
-
-def _reset():
- for entity in elixir.entities:
- for row in entity.query.filter_by().all():
- row.delete()
diff --git a/Mailman/database/model/address.py b/Mailman/database/model/address.py
index 3ba3c3dbf..022bbce36 100644
--- a/Mailman/database/model/address.py
+++ b/Mailman/database/model/address.py
@@ -15,31 +15,30 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
-from elixir import *
from email.utils import formataddr
+from storm.locals import *
from zope.interface import implements
from Mailman import Errors
+from Mailman.database import Model
from Mailman.interfaces import IAddress
-MEMBER_KIND = 'Mailman.database.model.member.Member'
-PREFERENCE_KIND = 'Mailman.database.model.preferences.Preferences'
-USER_KIND = 'Mailman.database.model.user.User'
-
-
-class Address(Entity):
+class Address(Model):
implements(IAddress)
- address = Field(Unicode)
- _original = Field(Unicode)
- real_name = Field(Unicode)
- verified_on = Field(DateTime)
- registered_on = Field(DateTime)
+ id = Int(primary=True)
+ address = Unicode()
+ _original = Unicode()
+ real_name = Unicode()
+ verified_on = DateTime()
+ registered_on = DateTime()
- user = ManyToOne(USER_KIND)
- preferences = ManyToOne(PREFERENCE_KIND)
+ user_id = Int()
+ user = Reference(user_id, 'User')
+ preferences_id = Int()
+ preferences = Reference(preferences_id, 'Preferences')
def __init__(self, address, real_name):
super(Address, self).__init__()
diff --git a/Mailman/database/model/language.py b/Mailman/database/model/language.py
index ffdbd2cba..a5229ab6a 100644
--- a/Mailman/database/model/language.py
+++ b/Mailman/database/model/language.py
@@ -15,14 +15,16 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
-from elixir import *
+from storm.locals import *
from zope.interface import implements
+from Mailman.database import Model
from Mailman.interfaces import ILanguage
-class Language(Entity):
+class Language(Model):
implements(ILanguage)
- code = Field(Unicode)
+ id = Int(primary=True)
+ code = Unicode()
diff --git a/Mailman/database/model/mailinglist.py b/Mailman/database/model/mailinglist.py
index 4057c2161..ed34a3aae 100644
--- a/Mailman/database/model/mailinglist.py
+++ b/Mailman/database/model/mailinglist.py
@@ -18,142 +18,145 @@
import os
import string
-from elixir import *
+from storm.locals import *
from zope.interface import implements
from Mailman.Utils import fqdn_listname, makedirs, split_listname
from Mailman.configuration import config
+from Mailman.database import Model
+from Mailman.database.types import Enum
from Mailman.interfaces import IMailingList, Personalization
-from Mailman.database.types import EnumType, TimeDeltaType
SPACE = ' '
UNDERSCORE = '_'
-class MailingList(Entity):
+class MailingList(Model):
implements(IMailingList)
+ id = Int(primary=True)
+
# List identity
- list_name = Field(Unicode)
- host_name = Field(Unicode)
+ list_name = Unicode()
+ host_name = Unicode()
# Attributes not directly modifiable via the web u/i
- created_at = Field(DateTime)
- web_page_url = Field(Unicode)
- admin_member_chunksize = Field(Integer)
- hold_and_cmd_autoresponses = Field(PickleType)
+ created_at = DateTime()
+ web_page_url = Unicode()
+ admin_member_chunksize = Int()
+ hold_and_cmd_autoresponses = Pickle()
# Attributes which are directly modifiable via the web u/i. The more
# complicated attributes are currently stored as pickles, though that
# will change as the schema and implementation is developed.
- next_request_id = Field(Integer)
- next_digest_number = Field(Integer)
- admin_responses = Field(PickleType)
- postings_responses = Field(PickleType)
- request_responses = Field(PickleType)
- digest_last_sent_at = Field(Float)
- one_last_digest = Field(PickleType)
- volume = Field(Integer)
- last_post_time = Field(DateTime)
+ next_request_id = Int()
+ next_digest_number = Int()
+ admin_responses = Pickle()
+ postings_responses = Pickle()
+ request_responses = Pickle()
+ digest_last_sent_at = Float()
+ one_last_digest = Pickle()
+ volume = Int()
+ last_post_time = DateTime()
# Attributes which are directly modifiable via the web u/i. The more
# complicated attributes are currently stored as pickles, though that
# will change as the schema and implementation is developed.
- accept_these_nonmembers = Field(PickleType)
- acceptable_aliases = Field(PickleType)
- admin_immed_notify = Field(Boolean)
- admin_notify_mchanges = Field(Boolean)
- administrivia = Field(Boolean)
- advertised = Field(Boolean)
- anonymous_list = Field(Boolean)
- archive = Field(Boolean)
- archive_private = Field(Boolean)
- archive_volume_frequency = Field(Integer)
- autorespond_admin = Field(Boolean)
- autorespond_postings = Field(Boolean)
- autorespond_requests = Field(Integer)
- autoresponse_admin_text = Field(Unicode)
- autoresponse_graceperiod = Field(TimeDeltaType)
- autoresponse_postings_text = Field(Unicode)
- autoresponse_request_text = Field(Unicode)
- ban_list = Field(PickleType)
- bounce_info_stale_after = Field(TimeDeltaType)
- bounce_matching_headers = Field(Unicode)
- bounce_notify_owner_on_disable = Field(Boolean)
- bounce_notify_owner_on_removal = Field(Boolean)
- bounce_processing = Field(Boolean)
- bounce_score_threshold = Field(Integer)
- bounce_unrecognized_goes_to_list_owner = Field(Boolean)
- bounce_you_are_disabled_warnings = Field(Integer)
- bounce_you_are_disabled_warnings_interval = Field(TimeDeltaType)
- collapse_alternatives = Field(Boolean)
- convert_html_to_plaintext = Field(Boolean)
- default_member_moderation = Field(Boolean)
- description = Field(Unicode)
- digest_footer = Field(Unicode)
- digest_header = Field(Unicode)
- digest_is_default = Field(Boolean)
- digest_send_periodic = Field(Boolean)
- digest_size_threshold = Field(Integer)
- digest_volume_frequency = Field(Integer)
- digestable = Field(Boolean)
- discard_these_nonmembers = Field(PickleType)
- emergency = Field(Boolean)
- encode_ascii_prefixes = Field(Boolean)
- filter_action = Field(Integer)
- filter_content = Field(Boolean)
- filter_filename_extensions = Field(PickleType)
- filter_mime_types = Field(PickleType)
- first_strip_reply_to = Field(Boolean)
- forward_auto_discards = Field(Boolean)
- gateway_to_mail = Field(Boolean)
- gateway_to_news = Field(Boolean)
- generic_nonmember_action = Field(Integer)
- goodbye_msg = Field(Unicode)
- header_filter_rules = Field(PickleType)
- hold_these_nonmembers = Field(PickleType)
- include_list_post_header = Field(Boolean)
- include_rfc2369_headers = Field(Boolean)
- info = Field(Unicode)
- linked_newsgroup = Field(Unicode)
- max_days_to_hold = Field(Integer)
- max_message_size = Field(Integer)
- max_num_recipients = Field(Integer)
- member_moderation_action = Field(Boolean)
- member_moderation_notice = Field(Unicode)
- mime_is_default_digest = Field(Boolean)
- moderator_password = Field(Unicode)
- msg_footer = Field(Unicode)
- msg_header = Field(Unicode)
- new_member_options = Field(Integer)
- news_moderation = Field(EnumType)
- news_prefix_subject_too = Field(Boolean)
- nntp_host = Field(Unicode)
- nondigestable = Field(Boolean)
- nonmember_rejection_notice = Field(Unicode)
- obscure_addresses = Field(Boolean)
- pass_filename_extensions = Field(PickleType)
- pass_mime_types = Field(PickleType)
- personalize = Field(EnumType)
- post_id = Field(Integer)
- preferred_language = Field(Unicode)
- private_roster = Field(Boolean)
- real_name = Field(Unicode)
- reject_these_nonmembers = Field(PickleType)
- reply_goes_to_list = Field(EnumType)
- reply_to_address = Field(Unicode)
- require_explicit_destination = Field(Boolean)
- respond_to_post_requests = Field(Boolean)
- scrub_nondigest = Field(Boolean)
- send_goodbye_msg = Field(Boolean)
- send_reminders = Field(Boolean)
- send_welcome_msg = Field(Boolean)
- subject_prefix = Field(Unicode)
- subscribe_auto_approval = Field(PickleType)
- subscribe_policy = Field(Integer)
- topics = Field(PickleType)
- topics_bodylines_limit = Field(Integer)
- topics_enabled = Field(Boolean)
- unsubscribe_policy = Field(Integer)
- welcome_msg = Field(Unicode)
+ accept_these_nonmembers = Pickle()
+ acceptable_aliases = Pickle()
+ admin_immed_notify = Bool()
+ admin_notify_mchanges = Bool()
+ administrivia = Bool()
+ advertised = Bool()
+ anonymous_list = Bool()
+ archive = Bool()
+ archive_private = Bool()
+ archive_volume_frequency = Int()
+ autorespond_admin = Bool()
+ autorespond_postings = Bool()
+ autorespond_requests = Int()
+ autoresponse_admin_text = Unicode()
+ autoresponse_graceperiod = TimeDelta()
+ autoresponse_postings_text = Unicode()
+ autoresponse_request_text = Unicode()
+ ban_list = Pickle()
+ bounce_info_stale_after = TimeDelta()
+ bounce_matching_headers = Unicode()
+ bounce_notify_owner_on_disable = Bool()
+ bounce_notify_owner_on_removal = Bool()
+ bounce_processing = Bool()
+ bounce_score_threshold = Int()
+ bounce_unrecognized_goes_to_list_owner = Bool()
+ bounce_you_are_disabled_warnings = Int()
+ bounce_you_are_disabled_warnings_interval = TimeDelta()
+ collapse_alternatives = Bool()
+ convert_html_to_plaintext = Bool()
+ default_member_moderation = Bool()
+ description = Unicode()
+ digest_footer = Unicode()
+ digest_header = Unicode()
+ digest_is_default = Bool()
+ digest_send_periodic = Bool()
+ digest_size_threshold = Int()
+ digest_volume_frequency = Int()
+ digestable = Bool()
+ discard_these_nonmembers = Pickle()
+ emergency = Bool()
+ encode_ascii_prefixes = Bool()
+ filter_action = Int()
+ filter_content = Bool()
+ filter_filename_extensions = Pickle()
+ filter_mime_types = Pickle()
+ first_strip_reply_to = Bool()
+ forward_auto_discards = Bool()
+ gateway_to_mail = Bool()
+ gateway_to_news = Bool()
+ generic_nonmember_action = Int()
+ goodbye_msg = Unicode()
+ header_filter_rules = Pickle()
+ hold_these_nonmembers = Pickle()
+ include_list_post_header = Bool()
+ include_rfc2369_headers = Bool()
+ info = Unicode()
+ linked_newsgroup = Unicode()
+ max_days_to_hold = Int()
+ max_message_size = Int()
+ max_num_recipients = Int()
+ member_moderation_action = Bool()
+ member_moderation_notice = Unicode()
+ mime_is_default_digest = Bool()
+ moderator_password = Unicode()
+ msg_footer = Unicode()
+ msg_header = Unicode()
+ new_member_options = Int()
+ news_moderation = Enum()
+ news_prefix_subject_too = Bool()
+ nntp_host = Unicode()
+ nondigestable = Bool()
+ nonmember_rejection_notice = Unicode()
+ obscure_addresses = Bool()
+ pass_filename_extensions = Pickle()
+ pass_mime_types = Pickle()
+ personalize = Enum()
+ post_id = Int()
+ preferred_language = Unicode()
+ private_roster = Bool()
+ real_name = Unicode()
+ reject_these_nonmembers = Pickle()
+ reply_goes_to_list = Enum()
+ reply_to_address = Unicode()
+ require_explicit_destination = Bool()
+ respond_to_post_requests = Bool()
+ scrub_nondigest = Bool()
+ send_goodbye_msg = Bool()
+ send_reminders = Bool()
+ send_welcome_msg = Bool()
+ subject_prefix = Unicode()
+ subscribe_auto_approval = Pickle()
+ subscribe_policy = Int()
+ topics = Pickle()
+ topics_bodylines_limit = Int()
+ topics_enabled = Bool()
+ unsubscribe_policy = Int()
+ welcome_msg = Unicode()
# Relationships
## has_and_belongs_to_many(
## 'available_languages',
diff --git a/Mailman/database/model/mailman.sql b/Mailman/database/model/mailman.sql
new file mode 100644
index 000000000..3dabad8c6
--- /dev/null
+++ b/Mailman/database/model/mailman.sql
@@ -0,0 +1,206 @@
+CREATE TABLE _request (
+ id INTEGER NOT NULL,
+ "key" TEXT,
+ type TEXT,
+ data_hash TEXT,
+ mailing_list_id INTEGER,
+ PRIMARY KEY (id),
+ CONSTRAINT _request_mailing_list_id_fk FOREIGN KEY(mailing_list_id) REFERENCES mailinglist (id)
+);
+CREATE TABLE address (
+ id INTEGER NOT NULL,
+ address TEXT,
+ _original TEXT,
+ real_name TEXT,
+ verified_on TIMESTAMP,
+ registered_on TIMESTAMP,
+ user_id INTEGER,
+ preferences_id INTEGER,
+ PRIMARY KEY (id),
+ CONSTRAINT address_user_id_fk FOREIGN KEY(user_id) REFERENCES user (id),
+ CONSTRAINT address_preferences_id_fk FOREIGN KEY(preferences_id) REFERENCES preferences (id)
+);
+CREATE TABLE language (
+ id INTEGER NOT NULL,
+ code TEXT,
+ PRIMARY KEY (id)
+);
+CREATE TABLE mailinglist (
+ id INTEGER NOT NULL,
+ list_name TEXT,
+ host_name TEXT,
+ created_at TIMESTAMP,
+ web_page_url TEXT,
+ admin_member_chunksize INTEGER,
+ hold_and_cmd_autoresponses BLOB,
+ next_request_id INTEGER,
+ next_digest_number INTEGER,
+ admin_responses BLOB,
+ postings_responses BLOB,
+ request_responses BLOB,
+ digest_last_sent_at NUMERIC(10, 2),
+ one_last_digest BLOB,
+ volume INTEGER,
+ last_post_time TIMESTAMP,
+ accept_these_nonmembers BLOB,
+ acceptable_aliases BLOB,
+ admin_immed_notify BOOLEAN,
+ admin_notify_mchanges BOOLEAN,
+ administrivia BOOLEAN,
+ advertised BOOLEAN,
+ anonymous_list BOOLEAN,
+ archive BOOLEAN,
+ archive_private BOOLEAN,
+ archive_volume_frequency INTEGER,
+ autorespond_admin BOOLEAN,
+ autorespond_postings BOOLEAN,
+ autorespond_requests INTEGER,
+ autoresponse_admin_text TEXT,
+ autoresponse_graceperiod TEXT,
+ autoresponse_postings_text TEXT,
+ autoresponse_request_text TEXT,
+ ban_list BLOB,
+ bounce_info_stale_after TEXT,
+ bounce_matching_headers TEXT,
+ bounce_notify_owner_on_disable BOOLEAN,
+ bounce_notify_owner_on_removal BOOLEAN,
+ bounce_processing BOOLEAN,
+ bounce_score_threshold INTEGER,
+ bounce_unrecognized_goes_to_list_owner BOOLEAN,
+ bounce_you_are_disabled_warnings INTEGER,
+ bounce_you_are_disabled_warnings_interval TEXT,
+ collapse_alternatives BOOLEAN,
+ convert_html_to_plaintext BOOLEAN,
+ default_member_moderation BOOLEAN,
+ description TEXT,
+ digest_footer TEXT,
+ digest_header TEXT,
+ digest_is_default BOOLEAN,
+ digest_send_periodic BOOLEAN,
+ digest_size_threshold INTEGER,
+ digest_volume_frequency INTEGER,
+ digestable BOOLEAN,
+ discard_these_nonmembers BLOB,
+ emergency BOOLEAN,
+ encode_ascii_prefixes BOOLEAN,
+ filter_action INTEGER,
+ filter_content BOOLEAN,
+ filter_filename_extensions BLOB,
+ filter_mime_types BLOB,
+ first_strip_reply_to BOOLEAN,
+ forward_auto_discards BOOLEAN,
+ gateway_to_mail BOOLEAN,
+ gateway_to_news BOOLEAN,
+ generic_nonmember_action INTEGER,
+ goodbye_msg TEXT,
+ header_filter_rules BLOB,
+ hold_these_nonmembers BLOB,
+ include_list_post_header BOOLEAN,
+ include_rfc2369_headers BOOLEAN,
+ info TEXT,
+ linked_newsgroup TEXT,
+ max_days_to_hold INTEGER,
+ max_message_size INTEGER,
+ max_num_recipients INTEGER,
+ member_moderation_action BOOLEAN,
+ member_moderation_notice TEXT,
+ mime_is_default_digest BOOLEAN,
+ moderator_password TEXT,
+ msg_footer TEXT,
+ msg_header TEXT,
+ new_member_options INTEGER,
+ news_moderation TEXT,
+ news_prefix_subject_too BOOLEAN,
+ nntp_host TEXT,
+ nondigestable BOOLEAN,
+ nonmember_rejection_notice TEXT,
+ obscure_addresses BOOLEAN,
+ pass_filename_extensions BLOB,
+ pass_mime_types BLOB,
+ personalize TEXT,
+ post_id INTEGER,
+ preferred_language TEXT,
+ private_roster BOOLEAN,
+ real_name TEXT,
+ reject_these_nonmembers BLOB,
+ reply_goes_to_list TEXT,
+ reply_to_address TEXT,
+ require_explicit_destination BOOLEAN,
+ respond_to_post_requests BOOLEAN,
+ scrub_nondigest BOOLEAN,
+ send_goodbye_msg BOOLEAN,
+ send_reminders BOOLEAN,
+ send_welcome_msg BOOLEAN,
+ subject_prefix TEXT,
+ subscribe_auto_approval BLOB,
+ subscribe_policy INTEGER,
+ topics BLOB,
+ topics_bodylines_limit INTEGER,
+ topics_enabled BOOLEAN,
+ unsubscribe_policy INTEGER,
+ welcome_msg TEXT,
+ PRIMARY KEY (id)
+);
+CREATE TABLE member (
+ id INTEGER NOT NULL,
+ role TEXT,
+ mailing_list TEXT,
+ address_id INTEGER,
+ preferences_id INTEGER,
+ PRIMARY KEY (id),
+ CONSTRAINT member_address_id_fk FOREIGN KEY(address_id) REFERENCES address (id),
+ CONSTRAINT member_preferences_id_fk FOREIGN KEY(preferences_id) REFERENCES preferences (id)
+);
+CREATE TABLE message (
+ id INTEGER NOT NULL,
+ hash TEXT,
+ path TEXT,
+ message_id TEXT,
+ PRIMARY KEY (id)
+);
+CREATE TABLE pended (
+ id INTEGER NOT NULL,
+ token TEXT,
+ expiration_date TIMESTAMP,
+ PRIMARY KEY (id)
+);
+CREATE TABLE pendedkeyvalue (
+ id INTEGER NOT NULL,
+ "key" TEXT,
+ value TEXT,
+ pended_id INTEGER,
+ PRIMARY KEY (id),
+ CONSTRAINT pendedkeyvalue_pended_id_fk FOREIGN KEY(pended_id) REFERENCES pended (id)
+);
+CREATE TABLE preferences (
+ id INTEGER NOT NULL,
+ acknowledge_posts BOOLEAN,
+ hide_address BOOLEAN,
+ preferred_language TEXT,
+ receive_list_copy BOOLEAN,
+ receive_own_postings BOOLEAN,
+ delivery_mode TEXT,
+ delivery_status TEXT,
+ PRIMARY KEY (id)
+);
+CREATE TABLE user (
+ id INTEGER NOT NULL,
+ real_name TEXT,
+ password TEXT,
+ preferences_id INTEGER,
+ PRIMARY KEY (id),
+ CONSTRAINT user_preferences_id_fk FOREIGN KEY(preferences_id) REFERENCES preferences (id)
+);
+CREATE TABLE version (
+ id INTEGER NOT NULL,
+ component TEXT,
+ version INTEGER,
+ PRIMARY KEY (id)
+);
+CREATE INDEX ix__request_mailing_list_id ON _request (mailing_list_id);
+CREATE INDEX ix_address_preferences_id ON address (preferences_id);
+CREATE INDEX ix_address_user_id ON address (user_id);
+CREATE INDEX ix_member_address_id ON member (address_id);
+CREATE INDEX ix_member_preferences_id ON member (preferences_id);
+CREATE INDEX ix_pendedkeyvalue_pended_id ON pendedkeyvalue (pended_id);
+CREATE INDEX ix_user_preferences_id ON user (preferences_id);
diff --git a/Mailman/database/model/member.py b/Mailman/database/model/member.py
index 4f353a06c..70a823a75 100644
--- a/Mailman/database/model/member.py
+++ b/Mailman/database/model/member.py
@@ -15,28 +15,28 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
-from elixir import *
+from storm.locals import *
from zope.interface import implements
from Mailman.Utils import split_listname
from Mailman.constants import SystemDefaultPreferences
-from Mailman.database.types import EnumType
+from Mailman.database import Model
+from Mailman.database.types import Enum
from Mailman.interfaces import IMember, IPreferences
-ADDRESS_KIND = 'Mailman.database.model.address.Address'
-PREFERENCE_KIND = 'Mailman.database.model.preferences.Preferences'
-
-
-class Member(Entity):
+class Member(Model):
implements(IMember)
- role = Field(EnumType)
- mailing_list = Field(Unicode)
- # Relationships
- address = ManyToOne(ADDRESS_KIND)
- preferences = ManyToOne(PREFERENCE_KIND)
+ id = Int(primary=True)
+ role = Enum()
+ mailing_list = Unicode()
+
+ address_id = Int()
+ address = Reference(address_id, 'Address')
+ preferences_id = Int()
+ preferences = Reference(preferences_id, 'Preferences')
def __repr__(self):
return '<Member: %s on %s as %s>' % (
diff --git a/Mailman/database/model/message.py b/Mailman/database/model/message.py
index eb4b4616d..7a6d7371a 100644
--- a/Mailman/database/model/message.py
+++ b/Mailman/database/model/message.py
@@ -15,18 +15,21 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
-from elixir import *
+from storm.locals import *
from zope.interface import implements
+from Mailman.database import Model
from Mailman.interfaces import IMessage
-class Message(Entity):
+class Message(Model):
"""A message in the message store."""
implements(IMessage)
- hash = Field(Unicode)
- path = Field(Unicode)
- message_id = Field(Unicode)
+ id = Int(primary=True)
+ hash = Unicode()
+ path = Unicode()
+ # This is a Messge-ID field representation, not a database row id.
+ message_id = Unicode()
diff --git a/Mailman/database/model/pending.py b/Mailman/database/model/pending.py
index 75bb59d3c..058b5de09 100644
--- a/Mailman/database/model/pending.py
+++ b/Mailman/database/model/pending.py
@@ -22,35 +22,36 @@ import random
import hashlib
import datetime
-from elixir import *
+from storm.locals import *
from zope.interface import implements
from zope.interface.verify import verifyObject
from Mailman.configuration import config
+from Mailman.database import Model
from Mailman.interfaces import (
IPendings, IPendable, IPendedKeyValue, IPended)
-PEND_KIND = 'Mailman.database.model.pending.Pended'
-
-class PendedKeyValue(Entity):
+class PendedKeyValue(Model):
"""A pended key/value pair, tied to a token."""
implements(IPendedKeyValue)
- key = Field(Unicode)
- value = Field(Unicode)
- pended = ManyToOne(PEND_KIND)
+ id = Int(primary=True)
+ key = Unicode()
+ value = Unicode()
-class Pended(Entity):
+class Pended(Model):
"""A pended event, tied to a token."""
implements(IPended)
- token = Field(Unicode)
- expiration_date = Field(DateTime)
+ id = Int(primary=True)
+ token = Unicode()
+ expiration_date = DateTime()
+ key_values = Reference(id, PendedKeyValue.id)
diff --git a/Mailman/database/model/preferences.py b/Mailman/database/model/preferences.py
index 8cbb77e6a..085e33e06 100644
--- a/Mailman/database/model/preferences.py
+++ b/Mailman/database/model/preferences.py
@@ -15,29 +15,27 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
-from elixir import *
from email.utils import formataddr
+from storm.locals import *
from zope.interface import implements
-from Mailman.database.types import EnumType
+from Mailman.database import Model
+from Mailman.database.types import Enum
from Mailman.interfaces import IPreferences
-ADDRESS_KIND = 'Mailman.database.model.address.Address'
-MEMBER_KIND = 'Mailman.database.model.member.Member'
-USER_KIND = 'Mailman.database.model.user.User'
-
-class Preferences(Entity):
+class Preferences(Model):
implements(IPreferences)
- acknowledge_posts = Field(Boolean)
- hide_address = Field(Boolean)
- preferred_language = Field(Unicode)
- receive_list_copy = Field(Boolean)
- receive_own_postings = Field(Boolean)
- delivery_mode = Field(EnumType)
- delivery_status = Field(EnumType)
+ id = Int(primary=True)
+ acknowledge_posts = Bool()
+ hide_address = Bool()
+ preferred_language = Unicode()
+ receive_list_copy = Bool()
+ receive_own_postings = Bool()
+ delivery_mode = Enum()
+ delivery_status = Enum()
def __repr__(self):
return '<Preferences object at %#x>' % id(self)
diff --git a/Mailman/database/model/requests.py b/Mailman/database/model/requests.py
index 037483c1a..d16e8f49d 100644
--- a/Mailman/database/model/requests.py
+++ b/Mailman/database/model/requests.py
@@ -18,17 +18,15 @@
"""Implementations of the IRequests and IListRequests interfaces."""
from datetime import timedelta
-from elixir import *
+from storm.locals import *
from zope.interface import implements
from Mailman.configuration import config
-from Mailman.database.types import EnumType
+from Mailman.database import Model
+from Mailman.database.types import Enum
from Mailman.interfaces import IListRequests, IPendable, IRequests, RequestType
-MAILINGLIST_KIND = 'Mailman.database.model.mailinglist.MailingList'
-
-
__metaclass__ = type
__all__ = [
'Requests',
@@ -127,11 +125,13 @@ class Requests:
-class _Request(Entity):
+class _Request(Model):
"""Table for mailing list hold requests."""
- key = Field(Unicode)
- type = Field(EnumType)
- data_hash = Field(Unicode)
- # Relationships
- mailing_list = ManyToOne(MAILINGLIST_KIND)
+ id = Int(primary=True)
+ key = Unicode()
+ type = Enum()
+ data_hash = Unicode()
+
+ mailing_list_id = Int()
+ mailing_list = Reference(mailing_list_id, 'MailingList')
diff --git a/Mailman/database/model/roster.py b/Mailman/database/model/roster.py
index c8fa86d58..5a01e7c7b 100644
--- a/Mailman/database/model/roster.py
+++ b/Mailman/database/model/roster.py
@@ -22,7 +22,6 @@ the ones that fit a particular role. These are used as the member, owner,
moderator, and administrator roster filters.
"""
-from sqlalchemy import *
from zope.interface import implements
from Mailman.constants import SystemDefaultPreferences
diff --git a/Mailman/database/model/user.py b/Mailman/database/model/user.py
index 17c388e0e..1ba5ba10e 100644
--- a/Mailman/database/model/user.py
+++ b/Mailman/database/model/user.py
@@ -15,28 +15,28 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
-from elixir import *
from email.utils import formataddr
+from storm.locals import *
from zope.interface import implements
from Mailman import Errors
+from Mailman.database import Model
from Mailman.database.model import Address
from Mailman.database.model import Preferences
from Mailman.interfaces import IUser
-ADDRESS_KIND = 'Mailman.database.model.address.Address'
-PREFERENCE_KIND = 'Mailman.database.model.preferences.Preferences'
-
-class User(Entity):
+class User(Model):
implements(IUser)
- real_name = Field(Unicode)
- password = Field(Unicode)
+ id = Int(primary=True)
+ real_name = Unicode()
+ password = Unicode()
- addresses = OneToMany(ADDRESS_KIND)
- preferences = ManyToOne(PREFERENCE_KIND)
+ addresses = ReferenceSet(id, 'Address.user_id')
+ preferences_id = Int()
+ preferences = Reference(preferences_id, 'Preferences')
def __repr__(self):
return '<User "%s" at %#x>' % (self.real_name, id(self))
diff --git a/Mailman/database/model/version.py b/Mailman/database/model/version.py
index dbbf5b8c1..2f4ff3f4d 100644
--- a/Mailman/database/model/version.py
+++ b/Mailman/database/model/version.py
@@ -15,9 +15,16 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
-from elixir import *
+from storm.locals import *
+from Mailman.database import Model
-class Version(Entity):
- component = Field(Unicode)
- version = Field(Integer)
+
+class Version(Model):
+ id = Int(primary=True)
+ component = Unicode()
+ version = Int()
+
+ def __init__(self, component, version):
+ self.component = component
+ self.version = version
diff --git a/Mailman/database/types.py b/Mailman/database/types.py
index 0f0e46fa3..ae71129cc 100644
--- a/Mailman/database/types.py
+++ b/Mailman/database/types.py
@@ -15,51 +15,43 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
+__all__ = [
+ 'Enum',
+ ]
+
+
import sys
-from datetime import timedelta
-from sqlalchemy import types
+from storm.properties import SimpleProperty
+from storm.variables import UnicodeVariable, Variable
-# SQLAlchemy custom type for storing munepy Enums in the database.
-class EnumType(types.TypeDecorator):
- # Enums can be stored as strings of the form:
- # full.path.to.Enum:intval
- impl = types.String
+class _EnumVariable(Variable):
+ """Storm variable."""
- def convert_bind_param(self, value, engine):
+ def parse_set(self, value, from_db):
if value is None:
return None
- return '%s.%s:%d' % (value.enumclass.__module__,
- value.enumclass.__name__,
- int(value))
+ if from_db:
+ path, intvalue = value.rsplit(':', 1)
+ modulename, classname = path.rsplit('.', 1)
+ __import__(modulename)
+ cls = getattr(sys.modules[modulename], classname)
+ return cls[int(intvalue)]
+ return value
- def convert_result_value(self, value, engine):
+ def parse_get(self, value, to_db):
if value is None:
return None
- path, intvalue = value.rsplit(':', 1)
- modulename, classname = path.rsplit('.', 1)
- __import__(modulename)
- cls = getattr(sys.modules[modulename], classname)
- return cls[int(intvalue)]
+ if to_db:
+ return '%s.%s:%d' % (value.enumclass.__module__,
+ value.enumclass.__name__,
+ int(value))
+ return value
-
-class TimeDeltaType(types.TypeDecorator):
- # timedeltas are stored as the string representation of three integers,
- # separated by colons. The values represent the three timedelta
- # attributes days, seconds, microseconds.
- impl = types.String
-
- def convert_bind_param(self, value, engine):
- if value is None:
- return None
- return '%s:%s:%s' % (value.days, value.seconds, value.microseconds)
+class Enum(SimpleProperty):
+ """Custom munepy.Enum type for Storm."""
- def convert_result_value(self, value, engine):
- if value is None:
- return None
- parts = value.split(':')
- assert len(parts) == 3, 'Bad timedelta representation: %s' % value
- return timedelta(*(int(value) for value in parts))
+ variable_class = UnicodeVariable
diff --git a/Mailman/database/usermanager.py b/Mailman/database/usermanager.py
index 6bc2ed53d..794b1cda1 100644
--- a/Mailman/database/usermanager.py
+++ b/Mailman/database/usermanager.py
@@ -15,18 +15,16 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
-"""SQLAlchemy/Elixir based provider of IUserManager."""
+"""A user manager."""
from __future__ import with_statement
import os
-from elixir import *
from zope.interface import implements
from Mailman import Errors
from Mailman.configuration import config
-from Mailman.database.model import *
from Mailman.interfaces import IUserManager
diff --git a/Mailman/docs/ack-headers.txt b/Mailman/docs/ack-headers.txt
index 156a9d530..4418fc4f8 100644
--- a/Mailman/docs/ack-headers.txt
+++ b/Mailman/docs/ack-headers.txt
@@ -7,14 +7,9 @@ transformations. Some headers get added, others get changed. Some of these
changes depend on mailing list settings and others depend on how the message
is getting sent through the system. We'll take things one-by-one.
- >>> from email import message_from_string
- >>> from Mailman.Message import Message
>>> from Mailman.Handlers.CookHeaders import process
- >>> from Mailman.configuration import config
- >>> from Mailman.database import flush
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
+ >>> mlist = config.db.list_manager.create(u'_xtest@example.com')
>>> mlist.subject_prefix = u''
- >>> flush()
When the message's metadata has a 'noack' key set, an 'X-Ack: no' header is
added.
@@ -23,17 +18,12 @@ added.
... From: aperson@example.com
...
... A message of great import.
- ... """, Message)
+ ... """)
>>> process(mlist, msg, dict(noack=True))
>>> print msg.as_string()
From: aperson@example.com
X-Ack: no
- X-BeenThere: _xtest@example.com
- X-Mailman-Version: ...
- Precedence: list
- <BLANKLINE>
- A message of great import.
- <BLANKLINE>
+ ...
Any existing X-Ack header in the original message is removed.
@@ -42,14 +32,9 @@ Any existing X-Ack header in the original message is removed.
... From: aperson@example.com
...
... A message of great import.
- ... """, Message)
+ ... """)
>>> process(mlist, msg, dict(noack=True))
>>> print msg.as_string()
From: aperson@example.com
X-Ack: no
- X-BeenThere: _xtest@example.com
- X-Mailman-Version: ...
- Precedence: list
- <BLANKLINE>
- A message of great import.
- <BLANKLINE>
+ ...
diff --git a/Mailman/tests/test_documentation.py b/Mailman/tests/test_documentation.py
index d8578bd05..c6ba0a1d6 100644
--- a/Mailman/tests/test_documentation.py
+++ b/Mailman/tests/test_documentation.py
@@ -22,8 +22,11 @@ import pdb
import doctest
import unittest
+from email import message_from_string
+
import Mailman
+from Mailman.Message import Message
from Mailman.app.styles import style_manager
from Mailman.configuration import config
from Mailman.database import flush
@@ -33,6 +36,17 @@ COMMASPACE = ', '
+def specialized_message_from_string(string):
+ return message_from_string(string, Message)
+
+
+def setup(testobj):
+ """Set up some things for convenience."""
+ testobj.globs['config'] = config
+ testobj.globs['message_from_string'] = specialized_message_from_string
+
+
+
def cleaning_teardown(testobj):
"""Clear all persistent data at the end of a doctest."""
# Clear the database of all rows.
@@ -69,6 +83,7 @@ def test_suite():
'docs/' + filename,
package=Mailman,
optionflags=flags,
+ setUp=setup,
tearDown=cleaning_teardown)
suite.addTest(test)
return suite
diff --git a/setup.py b/setup.py
index 18c73e788..22747880f 100644
--- a/setup.py
+++ b/setup.py
@@ -90,10 +90,10 @@ Any other spelling is incorrect.""",
},
# Third-party requirements.
install_requires = [
- 'Elixir>0.4.0',
'SQLAlchemy',
'locknix',
'munepy',
+ 'storm',
'wsgiref',
'zope.interface',
],