Commit da566eb0 authored by Barry Warsaw's avatar Barry Warsaw

* Updated NEWS.txt for 3.0a3.

* Use the IListManager() adapter instead of hanging the list manager off of
  config.db.  This makes the code somewhat cleaner.
parent e0693ed8
This diff is collapsed.
......@@ -49,6 +49,7 @@ from mailman import i18n
from mailman.Archiver import HyperDatabase
from mailman.Archiver import pipermail
from mailman.config import config
from mailman.interfaces.listmanager import IListManager
log = logging.getLogger('mailman.error')
......@@ -319,7 +320,7 @@ class Article(pipermail.Article):
listname = d.get('__listname')
if listname:
del d['__listname']
d['_mlist'] = config.db.list_manager.get(listname)
d['_mlist'] = IListManager(config).get(listname)
if not d.has_key('_lang'):
if hasattr(self, '_mlist'):
self._lang = self._mlist.preferred_language
......
......@@ -34,6 +34,7 @@ from mailman.config import config
from mailman.email.validate import validate
from mailman.interfaces.domain import (
BadDomainSpecificationError, IDomainManager)
from mailman.interfaces.listmanager import IListManager
from mailman.interfaces.member import MemberRole
from mailman.utilities.modules import call_name
......@@ -51,7 +52,7 @@ def create_list(fqdn_listname, owners=None):
listname, domain = fqdn_listname.split('@', 1)
if domain not in IDomainManager(config):
raise BadDomainSpecificationError(domain)
mlist = config.db.list_manager.create(fqdn_listname)
mlist = IListManager(config).create(fqdn_listname)
for style in config.style_manager.lookup(mlist):
style.apply(mlist)
# Coordinate with the MTA, as defined in the configuration file.
......@@ -80,7 +81,7 @@ def remove_list(fqdn_listname, mailing_list=None, archives=True):
for member in mailing_list.subscribers.members:
member.unsubscribe()
# Delete the mailing list from the database.
config.db.list_manager.delete(mailing_list)
IListManager(config).delete(mailing_list)
# Do the MTA-specific list deletion tasks
call_name(config.mta.incoming).create(mailing_list)
# Remove the list directory.
......
......@@ -35,6 +35,7 @@ from mailman.email.message import UserNotification
from mailman.email.validate import validate
from mailman.i18n import _
from mailman.interfaces.domain import IDomain
from mailman.interfaces.listmanager import IListManager
from mailman.interfaces.member import MemberRole
from mailman.interfaces.pending import IPendable
from mailman.interfaces.registrar import IRegistrar
......@@ -136,7 +137,7 @@ class Registrar:
# to the list right now.
list_name = pendable.get('list_name')
if list_name is not None:
mlist = config.db.list_manager.get(list_name)
mlist = IListManager(config).get(list_name)
if mlist:
addr.subscribe(mlist, MemberRole.member)
return True
......
......@@ -24,6 +24,7 @@ from mailman import Utils
from mailman.configuration import config
from mailman.i18n import _
from mailman.inject import inject_text
from mailman.interfaces.listmanager import IListManager
from mailman.message import Message
from mailman.options import SingleMailingListOptions
......@@ -71,7 +72,7 @@ def main():
options.parser.error(_('Bad queue directory: $qdir'))
fqdn_listname = options.options.listname
mlist = config.db.list_manager.get(fqdn_listname)
mlist = IListManager(config).get(fqdn_listname)
if mlist is None:
options.parser.error(_('No such list: $fqdn_listname'))
......
......@@ -39,7 +39,7 @@ from mailman.i18n import _, using_language
from mailman.interfaces.command import ICLISubCommand
from mailman.interfaces.domain import (
BadDomainSpecificationError, IDomainManager)
from mailman.interfaces.listmanager import ListAlreadyExistsError
from mailman.interfaces.listmanager import IListManager, ListAlreadyExistsError
......@@ -76,7 +76,7 @@ class Lists:
def process(self, args):
"""See `ICLISubCommand`."""
mailing_lists = []
list_manager = config.db.list_manager
list_manager = IListManager(config)
# Gather the matching mailing lists.
for fqdn_name in sorted(list_manager.names):
mlist = list_manager.get(fqdn_name)
......@@ -251,7 +251,7 @@ remove any residual archives."""))
assert len(args.listname) == 1, (
'Unexpected positional arguments: %s' % args.listname)
fqdn_listname = args.listname[0]
mlist = config.db.list_manager.get(fqdn_listname)
mlist = IListManager(config).get(fqdn_listname)
if mlist is None:
if args.archives:
log(_('No such list: $fqdn_listname; '
......
......@@ -35,6 +35,7 @@ from mailman.app.membership import add_member
from mailman.config import config
from mailman.i18n import _
from mailman.interfaces.command import ICLISubCommand
from mailman.interfaces.listmanager import IListManager
from mailman.interfaces.member import DeliveryMode
......@@ -67,7 +68,7 @@ class Members:
assert len(args.listname) == 1, (
'Unexpected positional arguments: %s' % args.listname)
fqdn_listname = args.listname[0]
mlist = config.db.list_manager.get(fqdn_listname)
mlist = IListManager(config).get(fqdn_listname)
if mlist is None:
self.parser.error(_('No such list: $fqdn_listname'))
if args.filename == '-':
......
......@@ -6,6 +6,12 @@
<!-- adapters -->
<adapter
for="mailman.config.config.IConfiguration"
provides="mailman.interfaces.listmanager.IListManager"
factory="mailman.database.listmanager.ListManager"
/>
<adapter
for="mailman.interfaces.domain.IDomain"
provides="mailman.interfaces.registrar.IRegistrar"
......
......@@ -36,7 +36,6 @@ from zope.interface import implements
import mailman.version
from mailman.config import config
from mailman.database.listmanager import ListManager
from mailman.database.messagestore import MessageStore
from mailman.database.pending import Pendings
from mailman.database.requests import Requests
......@@ -69,7 +68,6 @@ class StockDatabase:
# the database at the same time.
with Lock(os.path.join(config.LOCK_DIR, 'dbcreate.lck')):
self._create(debug)
self.list_manager = ListManager()
self.user_manager = UserManager()
self.message_store = MessageStore()
self.pendings = Pendings()
......
......@@ -29,7 +29,6 @@ import datetime
from zope.interface import implements
from mailman.config import config
from mailman.database.mailinglist import MailingList
from mailman.interfaces.listmanager import IListManager, ListAlreadyExistsError
from mailman.interfaces.rest import IResolvePathNames
......@@ -41,11 +40,20 @@ class ListManager(object):
implements(IListManager, IResolvePathNames)
def __init__(self, config):
"""Create a list manager.
:param config: The configuration object.
:type config: `IConfiguration`
"""
self.config = config
self.store = config.db.store
# pylint: disable-msg=R0201
def create(self, fqdn_listname):
"""See `IListManager`."""
listname, hostname = fqdn_listname.split('@', 1)
mlist = config.db.store.find(
mlist = self.store.find(
MailingList,
MailingList.list_name == listname,
MailingList.host_name == hostname).one()
......@@ -53,13 +61,13 @@ class ListManager(object):
raise ListAlreadyExistsError(fqdn_listname)
mlist = MailingList(fqdn_listname)
mlist.created_at = datetime.datetime.now()
config.db.store.add(mlist)
self.store.add(mlist)
return mlist
def get(self, fqdn_listname):
"""See `IListManager`."""
listname, hostname = fqdn_listname.split('@', 1)
mlist = config.db.store.find(MailingList,
mlist = self.store.find(MailingList,
list_name=listname,
host_name=hostname).one()
if mlist is not None:
......@@ -69,7 +77,7 @@ class ListManager(object):
def delete(self, mlist):
"""See `IListManager`."""
config.db.store.remove(mlist)
self.store.remove(mlist)
@property
def mailing_lists(self):
......@@ -80,7 +88,7 @@ class ListManager(object):
@property
def names(self):
"""See `IListManager`."""
for mlist in config.db.store.find(MailingList):
for mlist in self.store.find(MailingList):
yield '{0}@{1}'.format(mlist.list_name, mlist.host_name)
def get_mailing_lists(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment