summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mailman/config/configure.zcml16
-rw-r--r--src/mailman/config/schema.cfg4
-rw-r--r--src/mailman/database/__init__.py144
-rw-r--r--src/mailman/database/stock.py144
-rw-r--r--src/mailman/interfaces/database.py8
-rw-r--r--src/mailman/model/__init__.py0
-rw-r--r--src/mailman/model/address.py (renamed from src/mailman/database/address.py)4
-rw-r--r--src/mailman/model/autorespond.py (renamed from src/mailman/database/autorespond.py)0
-rw-r--r--src/mailman/model/digests.py (renamed from src/mailman/database/digests.py)0
-rw-r--r--src/mailman/model/domain.py (renamed from src/mailman/database/domain.py)0
-rw-r--r--src/mailman/model/language.py (renamed from src/mailman/database/language.py)0
-rw-r--r--src/mailman/model/listmanager.py (renamed from src/mailman/database/listmanager.py)2
-rw-r--r--src/mailman/model/mailinglist.py (renamed from src/mailman/database/mailinglist.py)6
-rw-r--r--src/mailman/model/member.py (renamed from src/mailman/database/member.py)0
-rw-r--r--src/mailman/model/message.py (renamed from src/mailman/database/message.py)0
-rw-r--r--src/mailman/model/messagestore.py (renamed from src/mailman/database/messagestore.py)2
-rw-r--r--src/mailman/model/mime.py (renamed from src/mailman/database/mime.py)0
-rw-r--r--src/mailman/model/pending.py (renamed from src/mailman/database/pending.py)2
-rw-r--r--src/mailman/model/preferences.py (renamed from src/mailman/database/preferences.py)0
-rw-r--r--src/mailman/model/requests.py (renamed from src/mailman/database/requests.py)0
-rw-r--r--src/mailman/model/roster.py (renamed from src/mailman/database/roster.py)6
-rw-r--r--src/mailman/model/user.py (renamed from src/mailman/database/user.py)6
-rw-r--r--src/mailman/model/usermanager.py (renamed from src/mailman/database/usermanager.py)8
-rw-r--r--src/mailman/model/version.py (renamed from src/mailman/database/version.py)0
24 files changed, 173 insertions, 179 deletions
diff --git a/src/mailman/config/configure.zcml b/src/mailman/config/configure.zcml
index 325a61f10..e4a5a5c78 100644
--- a/src/mailman/config/configure.zcml
+++ b/src/mailman/config/configure.zcml
@@ -15,44 +15,44 @@
<adapter
for="mailman.interfaces.mailinglist.IMailingList"
provides="mailman.interfaces.autorespond.IAutoResponseSet"
- factory="mailman.database.autorespond.AutoResponseSet"
+ factory="mailman.model.autorespond.AutoResponseSet"
/>
<adapter
for="mailman.interfaces.mailinglist.IMailingList"
provides="mailman.interfaces.mailinglist.IAcceptableAliasSet"
- factory="mailman.database.mailinglist.AcceptableAliasSet"
+ factory="mailman.model.mailinglist.AcceptableAliasSet"
/>
<adapter
for="mailman.config.config.IConfiguration"
provides="mailman.interfaces.domain.IDomainManager"
- factory="mailman.database.domain.DomainManager"
+ factory="mailman.model.domain.DomainManager"
/>
<!-- utilities -->
<utility
- factory="mailman.database.listmanager.ListManager"
+ factory="mailman.model.listmanager.ListManager"
provides="mailman.interfaces.listmanager.IListManager"
/>
<utility
- factory="mailman.database.usermanager.UserManager"
+ factory="mailman.model.usermanager.UserManager"
provides="mailman.interfaces.usermanager.IUserManager"
/>
<utility
- factory="mailman.database.messagestore.MessageStore"
+ factory="mailman.model.messagestore.MessageStore"
provides="mailman.interfaces.messages.IMessageStore"
/>
<utility
- factory="mailman.database.pending.Pendings"
+ factory="mailman.model.pending.Pendings"
provides="mailman.interfaces.pending.IPendings"
/>
<utility
- factory="mailman.database.requests.Requests"
+ factory="mailman.model.requests.Requests"
provides="mailman.interfaces.requests.IRequests"
/>
diff --git a/src/mailman/config/schema.cfg b/src/mailman/config/schema.cfg
index 1520c4726..103b726f5 100644
--- a/src/mailman/config/schema.cfg
+++ b/src/mailman/config/schema.cfg
@@ -105,8 +105,8 @@ max_restarts: 10
sleep_time: 1s
[database]
-# The class implementing the IDatabase interface.
-class: mailman.database.StockDatabase
+# The class implementing the IDatabase.
+class: mailman.database.stock.StockDatabase
# Use this to set the Storm database engine URL. You generally have one
# primary database connection for all of Mailman. List data and most rosters
diff --git a/src/mailman/database/__init__.py b/src/mailman/database/__init__.py
index 748378ca7..e69de29bb 100644
--- a/src/mailman/database/__init__.py
+++ b/src/mailman/database/__init__.py
@@ -1,144 +0,0 @@
-# Copyright (C) 2006-2009 by the Free Software Foundation, Inc.
-#
-# This file is part of GNU Mailman.
-#
-# GNU Mailman is free software: you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation, either version 3 of the License, or (at your option)
-# any later version.
-#
-# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-# more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import absolute_import, unicode_literals
-
-__metaclass__ = type
-__all__ = [
- 'StockDatabase',
- ]
-
-import os
-import logging
-
-from locknix.lockfile import Lock
-from lazr.config import as_boolean
-from pkg_resources import resource_string
-from storm.cache import GenerationalCache
-from storm.locals import create_database, Store
-from urlparse import urlparse
-from zope.interface import implements
-
-import mailman.version
-
-from mailman.config import config
-from mailman.database.messagestore import MessageStore
-from mailman.database.pending import Pendings
-from mailman.database.requests import Requests
-from mailman.database.version import Version
-from mailman.interfaces.database import IDatabase, SchemaVersionMismatchError
-from mailman.utilities.string import expand
-
-log = logging.getLogger('mailman.config')
-
-
-
-class StockDatabase:
- """The standard database, using Storm on top of SQLite."""
-
- implements(IDatabase)
-
- def __init__(self):
- self.url = None
- 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')):
- self._create(debug)
-
- 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 = expand(config.database.url, config.paths)
- log.debug('Database url: %s', url)
- # 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
- #
- # This sucks for us because the mailman.db file /must/ be group
- # writable, however even though we guarantee our umask is 002 here, it
- # still gets created without the necessary g+w permission, due to
- # SQLite's policy. This should only affect SQLite engines because its
- # the only one that creates a little file on the local file system.
- # This kludges around their bug by "touch"ing the database file before
- # SQLite has any chance to create it, thus honoring the umask and
- # ensuring the right 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...
- self.url = url
- touch(url)
- database = create_database(url)
- store = Store(database, GenerationalCache())
- database.DEBUG = (as_boolean(config.database.debug)
- if debug is None else debug)
- # Check the sqlite master database to see if the version file exists.
- # If so, then we assume the database schema is correctly initialized.
- # 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.
- table_names = [item[0] for item in
- store.execute('select tbl_name from sqlite_master;')]
- if 'version' not in table_names:
- # Initialize the database.
- sql = resource_string('mailman.database', 'mailman.sql')
- for statement in sql.split(';'):
- store.execute(statement + ';')
- # Validate schema version.
- v = store.find(Version, component='schema').one()
- if not v:
- # Database has not yet been initialized
- v = Version(component='schema',
- version=mailman.version.DATABASE_SCHEMA_VERSION)
- store.add(v)
- elif v.version <> mailman.version.DATABASE_SCHEMA_VERSION:
- # XXX Update schema
- raise SchemaVersionMismatchError(v.version)
- self.store = store
- store.commit()
-
- def _reset(self):
- """See `IDatabase`."""
- from mailman.database.model import ModelMeta
- self.store.rollback()
- ModelMeta._reset(self.store)
-
-
-
-def touch(url):
- parts = urlparse(url)
- if parts.scheme <> 'sqlite':
- return
- path = os.path.normpath(parts.path)
- fd = os.open(path, os.O_WRONLY | os.O_NONBLOCK | os.O_CREAT, 0666)
- # Ignore errors
- if fd > 0:
- os.close(fd)
diff --git a/src/mailman/database/stock.py b/src/mailman/database/stock.py
new file mode 100644
index 000000000..96d95fda4
--- /dev/null
+++ b/src/mailman/database/stock.py
@@ -0,0 +1,144 @@
+# Copyright (C) 2006-2009 by the Free Software Foundation, Inc.
+#
+# This file is part of GNU Mailman.
+#
+# GNU Mailman is free software: you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option)
+# any later version.
+#
+# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
+
+from __future__ import absolute_import, unicode_literals
+
+__metaclass__ = type
+__all__ = [
+ 'StockDatabase',
+ ]
+
+import os
+import logging
+
+from locknix.lockfile import Lock
+from lazr.config import as_boolean
+from pkg_resources import resource_string
+from storm.cache import GenerationalCache
+from storm.locals import create_database, Store
+from urlparse import urlparse
+from zope.interface import implements
+
+import mailman.version
+
+from mailman.config import config
+from mailman.interfaces.database import IDatabase, SchemaVersionMismatchError
+from mailman.model.messagestore import MessageStore
+from mailman.model.pending import Pendings
+from mailman.model.requests import Requests
+from mailman.model.version import Version
+from mailman.utilities.string import expand
+
+log = logging.getLogger('mailman.config')
+
+
+
+class StockDatabase:
+ """The standard database, using Storm on top of SQLite."""
+
+ implements(IDatabase)
+
+ def __init__(self):
+ self.url = None
+ 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')):
+ self._create(debug)
+
+ 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 = expand(config.database.url, config.paths)
+ log.debug('Database url: %s', url)
+ # 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
+ #
+ # This sucks for us because the mailman.db file /must/ be group
+ # writable, however even though we guarantee our umask is 002 here, it
+ # still gets created without the necessary g+w permission, due to
+ # SQLite's policy. This should only affect SQLite engines because its
+ # the only one that creates a little file on the local file system.
+ # This kludges around their bug by "touch"ing the database file before
+ # SQLite has any chance to create it, thus honoring the umask and
+ # ensuring the right 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...
+ self.url = url
+ touch(url)
+ database = create_database(url)
+ store = Store(database, GenerationalCache())
+ database.DEBUG = (as_boolean(config.database.debug)
+ if debug is None else debug)
+ # Check the sqlite master database to see if the version file exists.
+ # If so, then we assume the database schema is correctly initialized.
+ # 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.
+ table_names = [item[0] for item in
+ store.execute('select tbl_name from sqlite_master;')]
+ if 'version' not in table_names:
+ # Initialize the database.
+ sql = resource_string('mailman.database', 'mailman.sql')
+ for statement in sql.split(';'):
+ store.execute(statement + ';')
+ # Validate schema version.
+ v = store.find(Version, component='schema').one()
+ if not v:
+ # Database has not yet been initialized
+ v = Version(component='schema',
+ version=mailman.version.DATABASE_SCHEMA_VERSION)
+ store.add(v)
+ elif v.version <> mailman.version.DATABASE_SCHEMA_VERSION:
+ # XXX Update schema
+ raise SchemaVersionMismatchError(v.version)
+ self.store = store
+ store.commit()
+
+ def _reset(self):
+ """See `IDatabase`."""
+ from mailman.database.model import ModelMeta
+ self.store.rollback()
+ ModelMeta._reset(self.store)
+
+
+
+def touch(url):
+ parts = urlparse(url)
+ if parts.scheme <> 'sqlite':
+ return
+ path = os.path.normpath(parts.path)
+ fd = os.open(path, os.O_WRONLY | os.O_NONBLOCK | os.O_CREAT, 0666)
+ # Ignore errors
+ if fd > 0:
+ os.close(fd)
diff --git a/src/mailman/interfaces/database.py b/src/mailman/interfaces/database.py
index dd4294d4f..3730e7ade 100644
--- a/src/mailman/interfaces/database.py
+++ b/src/mailman/interfaces/database.py
@@ -15,13 +15,7 @@
# You should have received a copy of the GNU General Public License along with
# GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
-"""Interfaces for database interaction.
-
-By providing an object with this interface and declaring it in a package
-setup.py file as an entry point in the 'mailman.database' group with the name
-'initializer', you can distribute entirely different database layers for
-Mailman's back end.
-"""
+"""Interfaces for database interaction."""
from __future__ import absolute_import, unicode_literals
diff --git a/src/mailman/model/__init__.py b/src/mailman/model/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/mailman/model/__init__.py
diff --git a/src/mailman/database/address.py b/src/mailman/model/address.py
index f63f03e14..9b44c8b45 100644
--- a/src/mailman/database/address.py
+++ b/src/mailman/model/address.py
@@ -29,11 +29,11 @@ from email.utils import formataddr
from storm.locals import DateTime, Int, Reference, Store, Unicode
from zope.interface import implements
-from mailman.database.member import Member
from mailman.database.model import Model
-from mailman.database.preferences import Preferences
from mailman.interfaces.member import AlreadySubscribedError
from mailman.interfaces.address import IAddress
+from mailman.model.member import Member
+from mailman.model.preferences import Preferences
diff --git a/src/mailman/database/autorespond.py b/src/mailman/model/autorespond.py
index 0a84f30e3..0a84f30e3 100644
--- a/src/mailman/database/autorespond.py
+++ b/src/mailman/model/autorespond.py
diff --git a/src/mailman/database/digests.py b/src/mailman/model/digests.py
index 291dafa28..291dafa28 100644
--- a/src/mailman/database/digests.py
+++ b/src/mailman/model/digests.py
diff --git a/src/mailman/database/domain.py b/src/mailman/model/domain.py
index 9d4e714bc..9d4e714bc 100644
--- a/src/mailman/database/domain.py
+++ b/src/mailman/model/domain.py
diff --git a/src/mailman/database/language.py b/src/mailman/model/language.py
index 8adc5c4a5..8adc5c4a5 100644
--- a/src/mailman/database/language.py
+++ b/src/mailman/model/language.py
diff --git a/src/mailman/database/listmanager.py b/src/mailman/model/listmanager.py
index 929f00351..d4fd49cd0 100644
--- a/src/mailman/database/listmanager.py
+++ b/src/mailman/model/listmanager.py
@@ -31,9 +31,9 @@ from zope.interface import implements
from mailman.config import config
from mailman.core.errors import InvalidEmailAddress
-from mailman.database.mailinglist import MailingList
from mailman.interfaces.listmanager import IListManager, ListAlreadyExistsError
from mailman.interfaces.rest import IResolvePathNames
+from mailman.model.mailinglist import MailingList
diff --git a/src/mailman/database/mailinglist.py b/src/mailman/model/mailinglist.py
index 447d4657a..3aa103fac 100644
--- a/src/mailman/database/mailinglist.py
+++ b/src/mailman/model/mailinglist.py
@@ -35,15 +35,15 @@ from urlparse import urljoin
from zope.interface import implements
from mailman.config import config
-from mailman.database import roster
-from mailman.database.digests import OneLastDigest
-from mailman.database.mime import ContentFilter
from mailman.database.model import Model
from mailman.database.types import Enum
from mailman.interfaces.domain import IDomainManager
from mailman.interfaces.mailinglist import (
IAcceptableAlias, IAcceptableAliasSet, IMailingList, Personalization)
from mailman.interfaces.mime import FilterType
+from mailman.model import roster
+from mailman.model.digests import OneLastDigest
+from mailman.model.mime import ContentFilter
from mailman.utilities.filesystem import makedirs
from mailman.utilities.string import expand
diff --git a/src/mailman/database/member.py b/src/mailman/model/member.py
index 4a158a11e..4a158a11e 100644
--- a/src/mailman/database/member.py
+++ b/src/mailman/model/member.py
diff --git a/src/mailman/database/message.py b/src/mailman/model/message.py
index e77e11429..e77e11429 100644
--- a/src/mailman/database/message.py
+++ b/src/mailman/model/message.py
diff --git a/src/mailman/database/messagestore.py b/src/mailman/model/messagestore.py
index a129f47ec..7c83eb31e 100644
--- a/src/mailman/database/messagestore.py
+++ b/src/mailman/model/messagestore.py
@@ -34,8 +34,8 @@ import cPickle as pickle
from zope.interface import implements
from mailman.config import config
-from mailman.database.message import Message
from mailman.interfaces.messages import IMessageStore
+from mailman.model.message import Message
from mailman.utilities.filesystem import makedirs
diff --git a/src/mailman/database/mime.py b/src/mailman/model/mime.py
index 31c2aacbe..31c2aacbe 100644
--- a/src/mailman/database/mime.py
+++ b/src/mailman/model/mime.py
diff --git a/src/mailman/database/pending.py b/src/mailman/model/pending.py
index 2a0e5d09e..0409ad311 100644
--- a/src/mailman/database/pending.py
+++ b/src/mailman/model/pending.py
@@ -125,7 +125,7 @@ class Pendings:
value = '__builtin__.bool\1%s' % value
elif type(value) is list:
# We expect this to be a list of strings.
- value = ('mailman.database.pending.unpack_list\1' +
+ value = ('mailman.model.pending.unpack_list\1' +
'\2'.join(value))
keyval = PendedKeyValue(key=key, value=value)
pending.key_values.add(keyval)
diff --git a/src/mailman/database/preferences.py b/src/mailman/model/preferences.py
index 31f9ce280..31f9ce280 100644
--- a/src/mailman/database/preferences.py
+++ b/src/mailman/model/preferences.py
diff --git a/src/mailman/database/requests.py b/src/mailman/model/requests.py
index 538b97adb..538b97adb 100644
--- a/src/mailman/database/requests.py
+++ b/src/mailman/model/requests.py
diff --git a/src/mailman/database/roster.py b/src/mailman/model/roster.py
index 3b8ba4c4c..62e3ab5dc 100644
--- a/src/mailman/database/roster.py
+++ b/src/mailman/model/roster.py
@@ -41,11 +41,11 @@ from storm.expr import And, LeftJoin, Or
from zope.interface import implements
from mailman.config import config
-from mailman.database.address import Address
-from mailman.database.member import Member
-from mailman.database.preferences import Preferences
from mailman.interfaces.member import DeliveryMode, MemberRole
from mailman.interfaces.roster import IRoster
+from mailman.model.address import Address
+from mailman.model.member import Member
+from mailman.model.preferences import Preferences
diff --git a/src/mailman/database/user.py b/src/mailman/model/user.py
index 23701686b..75d3e1c88 100644
--- a/src/mailman/database/user.py
+++ b/src/mailman/model/user.py
@@ -29,12 +29,12 @@ from zope.interface import implements
from mailman.config import config
from mailman.database.model import Model
-from mailman.database.address import Address
-from mailman.database.preferences import Preferences
-from mailman.database.roster import Memberships
from mailman.interfaces.address import (
AddressAlreadyLinkedError, AddressNotLinkedError)
from mailman.interfaces.user import IUser
+from mailman.model.address import Address
+from mailman.model.preferences import Preferences
+from mailman.model.roster import Memberships
diff --git a/src/mailman/database/usermanager.py b/src/mailman/model/usermanager.py
index 0101bc8a5..baa5a4a1d 100644
--- a/src/mailman/database/usermanager.py
+++ b/src/mailman/model/usermanager.py
@@ -28,15 +28,15 @@ __all__ = [
from zope.interface import implements
from mailman.config import config
-from mailman.database.address import Address
-from mailman.database.preferences import Preferences
-from mailman.database.user import User
from mailman.interfaces.address import ExistingAddressError
from mailman.interfaces.usermanager import IUserManager
+from mailman.model.address import Address
+from mailman.model.preferences import Preferences
+from mailman.model.user import User
-class UserManager(object):
+class UserManager:
implements(IUserManager)
def create_user(self, address=None, real_name=None):
diff --git a/src/mailman/database/version.py b/src/mailman/model/version.py
index d15065395..d15065395 100644
--- a/src/mailman/database/version.py
+++ b/src/mailman/model/version.py