Commit dfccf2b7 authored by Barry Warsaw's avatar Barry Warsaw

Lots of changes to make bin/withlist work under a buildout environment.

mailman.configuration -> mailman.config.config
mailman.initialize -> mailma.core.initialize
mailman.loginit -> mailman.core.logging (yay future absolute imports!)

Convert all configurations to lazr.config, though some legacy still remains,
and I haven't been able to remove Defaults.py yet.  Added as_boolean() and
as_log_level() helpers for explicit type conversion.  Added a schema.cfg.
parent 33a924c5
...@@ -24,5 +24,6 @@ eggs = mailman ...@@ -24,5 +24,6 @@ eggs = mailman
[test] [test]
recipe = zc.recipe.testrunner recipe = zc.recipe.testrunner
eggs = mailman eggs =
mailman
defaults = '--tests-pattern ^tests --exit-with-status'.split() defaults = '--tests-pattern ^tests --exit-with-status'.split()
...@@ -34,7 +34,7 @@ from string import Template ...@@ -34,7 +34,7 @@ from string import Template
from mailman import Mailbox from mailman import Mailbox
from mailman import Utils from mailman import Utils
from mailman.configuration import config from mailman.config import config
from mailman.i18n import _ from mailman.i18n import _
log = logging.getLogger('mailman.error') log = logging.getLogger('mailman.error')
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
import os import os
import re import re
import sys import sys
import gzip
import time import time
import errno import errno
import urllib import urllib
...@@ -47,20 +48,13 @@ from mailman import i18n ...@@ -47,20 +48,13 @@ from mailman import i18n
from mailman.Archiver import HyperDatabase from mailman.Archiver import HyperDatabase
from mailman.Archiver import pipermail from mailman.Archiver import pipermail
from mailman.Mailbox import ArchiverMailbox from mailman.Mailbox import ArchiverMailbox
from mailman.configuration import config from mailman.config import config
log = logging.getLogger('mailman.error') log = logging.getLogger('mailman.error')
# Set up i18n. Assume the current language has already been set in the caller. # Set up i18n. Assume the current language has already been set in the caller.
_ = i18n._ _ = i18n._
gzip = None
if config.GZIP_ARCHIVE_TXT_FILES:
try:
import gzip
except ImportError:
pass
EMPTYSTRING = '' EMPTYSTRING = ''
NL = '\n' NL = '\n'
...@@ -239,7 +233,7 @@ class Article(pipermail.Article): ...@@ -239,7 +233,7 @@ class Article(pipermail.Article):
_last_article_time = time.time() _last_article_time = time.time()
def __init__(self, message=None, sequence=0, keepHeaders=[], def __init__(self, message=None, sequence=0, keepHeaders=[],
lang=config.DEFAULT_SERVER_LANGUAGE, mlist=None): lang=config.mailman.default_language, mlist=None):
self.__super_init(message, sequence, keepHeaders) self.__super_init(message, sequence, keepHeaders)
self.prev = None self.prev = None
self.next = None self.next = None
......
...@@ -27,7 +27,7 @@ from email.Generator import Generator ...@@ -27,7 +27,7 @@ from email.Generator import Generator
from email.Parser import Parser from email.Parser import Parser
from mailman.Message import Message from mailman.Message import Message
from mailman.configuration import config from mailman.config import config
......
...@@ -30,7 +30,7 @@ from email.charset import Charset ...@@ -30,7 +30,7 @@ from email.charset import Charset
from email.header import Header from email.header import Header
from mailman import Utils from mailman import Utils
from mailman.configuration import config from mailman.config import config
COMMASPACE = ', ' COMMASPACE = ', '
......
...@@ -41,7 +41,7 @@ from string import ascii_letters, digits, whitespace, Template ...@@ -41,7 +41,7 @@ from string import ascii_letters, digits, whitespace, Template
import mailman.templates import mailman.templates
from mailman import passwords from mailman import passwords
from mailman.configuration import config from mailman.config import config
from mailman.core import errors from mailman.core import errors
AT = '@' AT = '@'
......
...@@ -23,7 +23,7 @@ __all__ = [ ...@@ -23,7 +23,7 @@ __all__ = [
] ]
from mailman.configuration import config from mailman.config import config
from mailman.core.plugins import get_plugins from mailman.core.plugins import get_plugins
from mailman.interfaces import IEmailCommand from mailman.interfaces import IEmailCommand
......
...@@ -31,7 +31,7 @@ import logging ...@@ -31,7 +31,7 @@ import logging
from mailman import Utils from mailman import Utils
from mailman.Utils import ValidateEmail from mailman.Utils import ValidateEmail
from mailman.configuration import config from mailman.config import config
from mailman.core import errors from mailman.core import errors
from mailman.core.plugins import get_plugin from mailman.core.plugins import get_plugin
from mailman.core.styles import style_manager from mailman.core.styles import style_manager
......
...@@ -30,7 +30,7 @@ from mailman import Message ...@@ -30,7 +30,7 @@ from mailman import Message
from mailman import Utils from mailman import Utils
from mailman import i18n from mailman import i18n
from mailman.app.notifications import send_goodbye_message from mailman.app.notifications import send_goodbye_message
from mailman.configuration import config from mailman.config import config
from mailman.core import errors from mailman.core import errors
from mailman.interfaces import AlreadySubscribedError, DeliveryMode, MemberRole from mailman.interfaces import AlreadySubscribedError, DeliveryMode, MemberRole
......
...@@ -37,7 +37,7 @@ from mailman import i18n ...@@ -37,7 +37,7 @@ from mailman import i18n
from mailman.app.membership import add_member, delete_member from mailman.app.membership import add_member, delete_member
from mailman.app.notifications import ( from mailman.app.notifications import (
send_admin_subscription_notice, send_welcome_message) send_admin_subscription_notice, send_welcome_message)
from mailman.configuration import config from mailman.config import config
from mailman.core import errors from mailman.core import errors
from mailman.interfaces import Action, DeliveryMode, RequestType from mailman.interfaces import Action, DeliveryMode, RequestType
from mailman.interfaces.member import AlreadySubscribedError from mailman.interfaces.member import AlreadySubscribedError
......
...@@ -30,7 +30,7 @@ from email.utils import formataddr ...@@ -30,7 +30,7 @@ from email.utils import formataddr
from mailman import Message from mailman import Message
from mailman import Utils from mailman import Utils
from mailman import i18n from mailman import i18n
from mailman.configuration import config from mailman.config import config
from mailman.interfaces.member import DeliveryMode from mailman.interfaces.member import DeliveryMode
_ = i18n._ _ = i18n._
......
...@@ -31,7 +31,7 @@ from zope.interface import implements ...@@ -31,7 +31,7 @@ from zope.interface import implements
from mailman.Message import UserNotification from mailman.Message import UserNotification
from mailman.Utils import ValidateEmail from mailman.Utils import ValidateEmail
from mailman.configuration import config from mailman.config import config
from mailman.i18n import _ from mailman.i18n import _
from mailman.interfaces import IDomain, IPendable, IRegistrar from mailman.interfaces import IDomain, IPendable, IRegistrar
from mailman.interfaces.member import MemberRole from mailman.interfaces.member import MemberRole
......
...@@ -31,7 +31,7 @@ import datetime ...@@ -31,7 +31,7 @@ import datetime
from mailman import Utils from mailman import Utils
from mailman import i18n from mailman import i18n
from mailman.configuration import config from mailman.config import config
log = logging.getLogger('mailman.vette') log = logging.getLogger('mailman.vette')
......
...@@ -21,7 +21,7 @@ __all__ = [ ...@@ -21,7 +21,7 @@ __all__ = [
] ]
from mailman.configuration import config from mailman.config import config
from mailman.core.plugins import get_plugins from mailman.core.plugins import get_plugins
......
...@@ -30,7 +30,7 @@ from urllib import quote ...@@ -30,7 +30,7 @@ from urllib import quote
from urlparse import urljoin from urlparse import urljoin
from zope.interface import implements from zope.interface import implements
from mailman.configuration import config from mailman.config import config
from mailman.interfaces.archiver import IArchiver from mailman.interfaces.archiver import IArchiver
from mailman.queue import Switchboard from mailman.queue import Switchboard
......
...@@ -32,7 +32,7 @@ from string import Template ...@@ -32,7 +32,7 @@ from string import Template
from urlparse import urljoin from urlparse import urljoin
from zope.interface import implements from zope.interface import implements
from mailman.configuration import config from mailman.config import config
from mailman.interfaces.archiver import IArchiver from mailman.interfaces.archiver import IArchiver
......
...@@ -30,7 +30,7 @@ from string import Template ...@@ -30,7 +30,7 @@ from string import Template
from zope.interface import implements from zope.interface import implements
from zope.interface.interface import adapter_hooks from zope.interface.interface import adapter_hooks
from mailman.configuration import config from mailman.config import config
from mailman.interfaces.archiver import IArchiver, IPipermailMailingList from mailman.interfaces.archiver import IArchiver, IPipermailMailingList
from mailman.interfaces.mailinglist import IMailingList from mailman.interfaces.mailinglist import IMailingList
......
...@@ -29,7 +29,7 @@ from base64 import b32encode ...@@ -29,7 +29,7 @@ from base64 import b32encode
from urlparse import urljoin from urlparse import urljoin
from zope.interface import implements from zope.interface import implements
from mailman.configuration import config from mailman.config import config
from mailman.interfaces.archiver import IArchiver from mailman.interfaces.archiver import IArchiver
......
...@@ -36,8 +36,8 @@ from locknix import lockfile ...@@ -36,8 +36,8 @@ from locknix import lockfile
from munepy import Enum from munepy import Enum
from mailman import Defaults from mailman import Defaults
from mailman import loginit from mailman.config import config
from mailman.configuration import config from mailman.core.logging import reopen
from mailman.i18n import _ from mailman.i18n import _
from mailman.options import Options from mailman.options import Options
...@@ -237,7 +237,7 @@ class Loop: ...@@ -237,7 +237,7 @@ class Loop:
signal.alarm(int(Defaults.days(1))) signal.alarm(int(Defaults.days(1)))
# SIGHUP tells the qrunners to close and reopen their log files. # SIGHUP tells the qrunners to close and reopen their log files.
def sighup_handler(signum, frame): def sighup_handler(signum, frame):
loginit.reopen() reopen()
for pid in self._kids: for pid in self._kids:
os.kill(pid, signal.SIGHUP) os.kill(pid, signal.SIGHUP)
log.info('Master watcher caught SIGHUP. Re-opening log files.') log.info('Master watcher caught SIGHUP. Re-opening log files.')
......
...@@ -20,9 +20,9 @@ import sys ...@@ -20,9 +20,9 @@ import sys
import optparse import optparse
from mailman import interact from mailman import interact
from mailman.configuration import config from mailman.config import config
from mailman.core.initialize import initialize
from mailman.i18n import _ from mailman.i18n import _
from mailman.initialize import initialize
from mailman.version import MAILMAN_VERSION from mailman.version import MAILMAN_VERSION
......
...@@ -23,7 +23,7 @@ __metaclass__ = type ...@@ -23,7 +23,7 @@ __metaclass__ = type
import logging import logging
from mailman.chains.base import TerminalChainBase from mailman.chains.base import TerminalChainBase
from mailman.configuration import config from mailman.config import config
from mailman.i18n import _ from mailman.i18n import _
from mailman.queue import Switchboard from mailman.queue import Switchboard
......
...@@ -27,7 +27,7 @@ __all__ = [ ...@@ -27,7 +27,7 @@ __all__ = [
from zope.interface import implements from zope.interface import implements
from mailman.configuration import config from mailman.config import config
from mailman.interfaces import ( from mailman.interfaces import (
IChain, IChainIterator, IChainLink, IMutableChain, LinkAction) IChain, IChainIterator, IChainLink, IMutableChain, LinkAction)
......
...@@ -26,7 +26,7 @@ import logging ...@@ -26,7 +26,7 @@ import logging
from zope.interface import implements from zope.interface import implements
from mailman.chains.base import Link from mailman.chains.base import Link
from mailman.configuration import config from mailman.config import config
from mailman.i18n import _ from mailman.i18n import _
from mailman.interfaces import IChain, LinkAction from mailman.interfaces import IChain, LinkAction
......
...@@ -30,7 +30,7 @@ from zope.interface import implements ...@@ -30,7 +30,7 @@ from zope.interface import implements
from mailman.interfaces import IChainIterator, IRule, LinkAction from mailman.interfaces import IChainIterator, IRule, LinkAction
from mailman.chains.base import Chain, Link from mailman.chains.base import Chain, Link
from mailman.i18n import _ from mailman.i18n import _
from mailman.configuration import config from mailman.config import config
log = logging.getLogger('mailman.vette') log = logging.getLogger('mailman.vette')
...@@ -104,7 +104,7 @@ class HeaderMatchChain(Chain): ...@@ -104,7 +104,7 @@ class HeaderMatchChain(Chain):
self._links = [] self._links = []
# Initialize header check rules with those from the global # Initialize header check rules with those from the global
# HEADER_MATCHES variable. # HEADER_MATCHES variable.
for entry in config.HEADER_MATCHES: for entry in config.header_matches:
self._links.append(make_link(entry)) self._links.append(make_link(entry))
# Keep track of how many global header matching rules we've seen. # Keep track of how many global header matching rules we've seen.
# This is so the flush() method will only delete those that were added # This is so the flush() method will only delete those that were added
......
...@@ -36,7 +36,7 @@ from mailman.Utils import maketext, oneline, wrap, GetCharSet ...@@ -36,7 +36,7 @@ from mailman.Utils import maketext, oneline, wrap, GetCharSet
from mailman.app.moderator import hold_message from mailman.app.moderator import hold_message
from mailman.app.replybot import autorespond_to_sender, can_acknowledge from mailman.app.replybot import autorespond_to_sender, can_acknowledge
from mailman.chains.base import TerminalChainBase from mailman.chains.base import TerminalChainBase
from mailman.configuration import config from mailman.config import config
from mailman.interfaces import IPendable from mailman.interfaces import IPendable
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
from mailman import Errors from mailman import Errors
from mailman import Pending from mailman import Pending
from mailman.configuration import config from mailman.config import config
from mailman.i18n import _ from mailman.i18n import _
STOP = 1 STOP = 1
......
...@@ -24,7 +24,7 @@ import os ...@@ -24,7 +24,7 @@ import os
import sys import sys
from mailman import Utils from mailman import Utils
from mailman.configuration import config from mailman.config import config
from mailman.i18n import _ from mailman.i18n import _
EMPTYSTRING = '' EMPTYSTRING = ''
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
""" """
from mailman.MailList import MailList from mailman.MailList import MailList
from mailman.configuration import config from mailman.config import config
from mailman.i18n import _ from mailman.i18n import _
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
from email.Utils import parseaddr from email.Utils import parseaddr
from mailman.configuration import config from mailman.config import config
from mailman.i18n import _ from mailman.i18n import _
STOP = 1 STOP = 1
......
...@@ -20,7 +20,7 @@ from email.Utils import parseaddr, formatdate ...@@ -20,7 +20,7 @@ from email.Utils import parseaddr, formatdate
from mailman import Errors from mailman import Errors
from mailman import MemberAdaptor from mailman import MemberAdaptor
from mailman import i18n from mailman import i18n
from mailman.configuration import config from mailman.config import config
def _(s): return s def _(s): return s
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
from email.Utils import parseaddr from email.Utils import parseaddr
from mailman import i18n from mailman import i18n
from mailman.configuration import config from mailman.config import config
STOP = 1 STOP = 1
......
...@@ -29,7 +29,7 @@ from email.utils import formataddr, parseaddr ...@@ -29,7 +29,7 @@ from email.utils import formataddr, parseaddr
from zope.interface import implements from zope.interface import implements
from mailman.Utils import MakeRandomPassword from mailman.Utils import MakeRandomPassword
from mailman.configuration import config from mailman.config import config
from mailman.i18n import _ from mailman.i18n import _
from mailman.interfaces import ( from mailman.interfaces import (
ContinueProcessing, DeliveryMode, IEmailCommand) ContinueProcessing, DeliveryMode, IEmailCommand)
......
# Copyright (C) 2008 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 mailman.config.config import Configuration
config = Configuration()
# Copyright (C) 2008 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/>.
"""Configuration helpers."""
__metaclass__ = type
__all__ = [
'as_boolean',
'as_log_level',
]
import logging
def as_boolean(value):
"""Turn a string into a boolean.
:param value: A string with one of the following values
(case-insensitive): true, yes, 1, on, enable, enabled (for True), or
false, no, 0, off, disable, disabled (for False). Everything else is
an error.
:type value: string
:return: True or False.
:rtype: boolean
"""
value = value.lower()
if value in ('true', 'yes', '1', 'on', 'enabled', 'enable'):
return True
if value in ('false', 'no', '0', 'off', 'disabled', 'disable'):
return False
raise ValueError('Invalid boolean value: %s' % value)
def as_log_level(value):
"""Turn a string into a log level.
:param value: A string with a value (case-insensitive) equal to one of the
symbolic logging levels.
:type value: string
:return: A logging level constant.
:rtype: int
"""
value = value.upper()
return getattr(logging, value)
# Copyright (C) 2008 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/>.
# This is the GNU Mailman configuration schema. It defines the default
# configuration options for the core system and plugins. It uses ini-style
# formats under the lazr.config regime to define all system configuration
# options. See <https://launchpad.net/lazr.config> for details. You can
# override the defaults by creating a mailman.cfg file in your etc directory.
# See mailman.cfg.sample as an example.
[mailman]
# This address is the "site owner" address. Certain messages which must be
# delivered to a human, but which can't be delivered to a list owner (e.g. a
# bounce from a list owner), will be sent to this address. It should point to
# a human.
site-owner: [email protected]
# This address is used as the from address whenever a message comes from some
# entity to which there is no natural reply recipient. Set this to a real
# human or to /dev/null. It will be appended with the host name of the list
# involved. This address must not bounce and it must not point to a Mailman
# process.
noreply-address: noreply
# Where all the runtime data will be kept. This directory must exist.
var_dir: /tmp/mailman
# The default language for this server.
default_language: en
[qrunner.template]
# Define which process queue runners, and how many of them, to start.
class: mailman.queue.runner.Runner
count: 1
start: yes
[qrunner.archive]
class: mailman.queue.archive.ArchiveRunner
[qrunner.bounce]
class: mailman.queue.bounce.BounceRunner
[qrunner.command]
class: mailman.queue.command.CommandRunner
[qrunner.incoming]
class: mailman.queue.incoming.IncomingRunner
[qrunner.news]
class: mailman.queue.news.NewsRunner
[qrunner.outgoing]
class: mailman.queue.outgoing.OutgoingRunner
[qrunner.pipeline]
class: mailman.queue.pipeline.PipelineRunner
[qrunner.retry]
class: mailman.queue.retry.RetryRunner
[qrunner.virgin]
class: mailman.queue.virgin.VirginRunner
[qrunner.lmtp]
class: mailman.queue.lmtp.LMTPRunner
[database]
# 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
# will store their data in this database, although external rosters may access
# other databases in their own way. This string supports standard
# 'configuration' substitutions.
url: sqlite:///$DATA_DIR/mailman.db
debug: no
[logging.template]
# This defines various log settings. The options available are:
#
# - level -- Overrides the default level; this may be any of the
# standard Python logging levels, case insensitive.
# - format -- Overrides the default format string
# - datefmt -- Overrides the default date format string
# - path -- Overrides the default logger path. This may be a relative