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
[test]
recipe = zc.recipe.testrunner
eggs = mailman
eggs =
mailman
defaults = '--tests-pattern ^tests --exit-with-status'.split()
......@@ -34,7 +34,7 @@ from string import Template
from mailman import Mailbox
from mailman import Utils
from mailman.configuration import config
from mailman.config import config
from mailman.i18n import _
log = logging.getLogger('mailman.error')
......
......@@ -29,6 +29,7 @@
import os
import re
import sys
import gzip
import time
import errno
import urllib
......@@ -47,20 +48,13 @@ from mailman import i18n
from mailman.Archiver import HyperDatabase
from mailman.Archiver import pipermail
from mailman.Mailbox import ArchiverMailbox
from mailman.configuration import config
from mailman.config import config
log = logging.getLogger('mailman.error')
# Set up i18n. Assume the current language has already been set in the caller.
_ = i18n._
gzip = None
if config.GZIP_ARCHIVE_TXT_FILES:
try:
import gzip
except ImportError:
pass
EMPTYSTRING = ''
NL = '\n'
......@@ -239,7 +233,7 @@ class Article(pipermail.Article):
_last_article_time = time.time()
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.prev = None
self.next = None
......
......@@ -27,7 +27,7 @@ from email.Generator import Generator
from email.Parser import Parser
from mailman.Message import Message
from mailman.configuration import config
from mailman.config import config
......
......@@ -30,7 +30,7 @@ from email.charset import Charset
from email.header import Header
from mailman import Utils
from mailman.configuration import config
from mailman.config import config
COMMASPACE = ', '
......
......@@ -41,7 +41,7 @@ from string import ascii_letters, digits, whitespace, Template
import mailman.templates
from mailman import passwords
from mailman.configuration import config
from mailman.config import config
from mailman.core import errors
AT = '@'
......
......@@ -23,7 +23,7 @@ __all__ = [
]
from mailman.configuration import config
from mailman.config import config
from mailman.core.plugins import get_plugins
from mailman.interfaces import IEmailCommand
......
......@@ -31,7 +31,7 @@ import logging
from mailman import Utils
from mailman.Utils import ValidateEmail
from mailman.configuration import config
from mailman.config import config
from mailman.core import errors
from mailman.core.plugins import get_plugin
from mailman.core.styles import style_manager
......
......@@ -30,7 +30,7 @@ from mailman import Message
from mailman import Utils
from mailman import i18n
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.interfaces import AlreadySubscribedError, DeliveryMode, MemberRole
......
......@@ -37,7 +37,7 @@ from mailman import i18n
from mailman.app.membership import add_member, delete_member
from mailman.app.notifications import (
send_admin_subscription_notice, send_welcome_message)
from mailman.configuration import config
from mailman.config import config
from mailman.core import errors
from mailman.interfaces import Action, DeliveryMode, RequestType
from mailman.interfaces.member import AlreadySubscribedError
......
......@@ -30,7 +30,7 @@ from email.utils import formataddr
from mailman import Message
from mailman import Utils
from mailman import i18n
from mailman.configuration import config
from mailman.config import config
from mailman.interfaces.member import DeliveryMode
_ = i18n._
......
......@@ -31,7 +31,7 @@ from zope.interface import implements
from mailman.Message import UserNotification
from mailman.Utils import ValidateEmail
from mailman.configuration import config
from mailman.config import config
from mailman.i18n import _
from mailman.interfaces import IDomain, IPendable, IRegistrar
from mailman.interfaces.member import MemberRole
......
......@@ -31,7 +31,7 @@ import datetime
from mailman import Utils
from mailman import i18n
from mailman.configuration import config
from mailman.config import config
log = logging.getLogger('mailman.vette')
......
......@@ -21,7 +21,7 @@ __all__ = [
]
from mailman.configuration import config
from mailman.config import config
from mailman.core.plugins import get_plugins
......
......@@ -30,7 +30,7 @@ from urllib import quote
from urlparse import urljoin
from zope.interface import implements
from mailman.configuration import config
from mailman.config import config
from mailman.interfaces.archiver import IArchiver
from mailman.queue import Switchboard
......
......@@ -32,7 +32,7 @@ from string import Template
from urlparse import urljoin
from zope.interface import implements
from mailman.configuration import config
from mailman.config import config
from mailman.interfaces.archiver import IArchiver
......
......@@ -30,7 +30,7 @@ from string import Template
from zope.interface import implements
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.mailinglist import IMailingList
......
......@@ -29,7 +29,7 @@ from base64 import b32encode
from urlparse import urljoin
from zope.interface import implements
from mailman.configuration import config
from mailman.config import config
from mailman.interfaces.archiver import IArchiver
......
......@@ -36,8 +36,8 @@ from locknix import lockfile
from munepy import Enum
from mailman import Defaults
from mailman import loginit
from mailman.configuration import config
from mailman.config import config
from mailman.core.logging import reopen
from mailman.i18n import _
from mailman.options import Options
......@@ -237,7 +237,7 @@ class Loop:
signal.alarm(int(Defaults.days(1)))
# SIGHUP tells the qrunners to close and reopen their log files.
def sighup_handler(signum, frame):
loginit.reopen()
reopen()
for pid in self._kids:
os.kill(pid, signal.SIGHUP)
log.info('Master watcher caught SIGHUP. Re-opening log files.')
......
......@@ -20,9 +20,9 @@ import sys
import optparse
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.initialize import initialize
from mailman.version import MAILMAN_VERSION
......
......@@ -23,7 +23,7 @@ __metaclass__ = type
import logging
from mailman.chains.base import TerminalChainBase
from mailman.configuration import config
from mailman.config import config
from mailman.i18n import _
from mailman.queue import Switchboard
......
......@@ -27,7 +27,7 @@ __all__ = [
from zope.interface import implements
from mailman.configuration import config
from mailman.config import config
from mailman.interfaces import (
IChain, IChainIterator, IChainLink, IMutableChain, LinkAction)
......
......@@ -26,7 +26,7 @@ import logging
from zope.interface import implements
from mailman.chains.base import Link
from mailman.configuration import config
from mailman.config import config
from mailman.i18n import _
from mailman.interfaces import IChain, LinkAction
......
......@@ -30,7 +30,7 @@ from zope.interface import implements
from mailman.interfaces import IChainIterator, IRule, LinkAction
from mailman.chains.base import Chain, Link
from mailman.i18n import _
from mailman.configuration import config
from mailman.config import config
log = logging.getLogger('mailman.vette')
......@@ -104,7 +104,7 @@ class HeaderMatchChain(Chain):
self._links = []
# Initialize header check rules with those from the global
# HEADER_MATCHES variable.
for entry in config.HEADER_MATCHES:
for entry in config.header_matches:
self._links.append(make_link(entry))
# 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
......
......@@ -36,7 +36,7 @@ from mailman.Utils import maketext, oneline, wrap, GetCharSet
from mailman.app.moderator import hold_message
from mailman.app.replybot import autorespond_to_sender, can_acknowledge
from mailman.chains.base import TerminalChainBase
from mailman.configuration import config
from mailman.config import config
from mailman.interfaces import IPendable
......
......@@ -23,7 +23,7 @@
from mailman import Errors
from mailman import Pending
from mailman.configuration import config
from mailman.config import config
from mailman.i18n import _
STOP = 1
......
......@@ -24,7 +24,7 @@ import os
import sys
from mailman import Utils
from mailman.configuration import config
from mailman.config import config
from mailman.i18n import _
EMPTYSTRING = ''
......
......@@ -21,7 +21,7 @@
"""
from mailman.MailList import MailList
from mailman.configuration import config
from mailman.config import config
from mailman.i18n import _
......
......@@ -29,7 +29,7 @@
from email.Utils import parseaddr
from mailman.configuration import config
from mailman.config import config
from mailman.i18n import _
STOP = 1
......
......@@ -20,7 +20,7 @@ from email.Utils import parseaddr, formatdate
from mailman import Errors
from mailman import MemberAdaptor
from mailman import i18n
from mailman.configuration import config
from mailman.config import config
def _(s): return s
......
......@@ -18,7 +18,7 @@
from email.Utils import parseaddr
from mailman import i18n
from mailman.configuration import config
from mailman.config import config
STOP = 1
......
......@@ -29,7 +29,7 @@ from email.utils import formataddr, parseaddr
from zope.interface import implements
from mailman.Utils import MakeRandomPassword
from mailman.configuration import config
from mailman.config import config
from mailman.i18n import _
from mailman.interfaces import (
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
# path name, in which case it is relative to Mailman's LOG_DIR,
# or it may be an absolute path name. You cannot change the
# handler class that will be used.
# - propagate -- Boolean specifying whether to propagate log message from this
# logger to the root "mailman" logger. You cannot override
# settings for the root logger.
#
# In this section, you can define defaults for all loggers, which will be
# prefixed by 'mailman.'. Use subsections to override settings for specific
# loggers. The names of the available loggers are:
#
# - archiver -- All archiver output
# - bounce -- All bounce processing logs go here
# - config -- Configuration issues
# - debug -- Only used for development
# - error -- All exceptions go to this log
# - fromusenet -- Information related to the Usenet to Mailman gateway
# - http -- Internal wsgi-based web interface
# - locks -- Lock state changes
# - mischief -- Various types of hostile activity
# - post -- Information about messages posted to mailing lists
# - qrunner -- qrunner start/stops
# - smtp -- Successful SMTP activity
# - smtp-failure -- Unsuccessful SMTP activity
# - subscribe -- Information about leaves/joins
# - vette -- Information related to admindb activity
format: %(asctime)s (%(process)d) %(message)s
datefmt: %b %d %H:%M:%S %Y
propagate: no
level: info
path: mailman
[logging.root]
[logging.archiver]
[logging.bounce]
path: bounce
[logging.config]
[logging.debug]
path: debug
level: debug
[logging.error]
[logging.fromusenet]
[logging.http]
[logging.locks]
[logging.mischief]
[logging.qrunner]
[logging.smtp]
path: smtp
# The smtp logger defines additional options for handling the logging of each
# attempted delivery. These format strings specify what information is logged
# for every message, every successful delivery, every refused delivery and
# every recipient failure. To disable a status message, set the value to 'no'
# (without the quotes).
#
# These template strings accept the following set of substitution
# placeholders, if available.
#
# msgid -- the Message-ID of the message in question
# listname -- the fully-qualified list name
# sender -- the sender if available
# recip -- the recipient address if available, or the number of
# recipients being delivered to
# size -- the approximate size of the message in bytes
# seconds -- the number of seconds the operation took
# refused -- the number of refused recipients
# smtpcode -- the SMTP success or failure code
# smtpmsg -- the SMTP success or failure message
every: [$msgid] smtp to $listname for $recip recips, completed in $time seconds
success: [$msgid] post to $listname from $sender, $size bytes
refused: [$msgid] post to $listname from $sender, $size bytes, $refused failures
failure: [$msgid] delivery to $recip failed with code $smtpcode, $smtpmsg
[logging.subscribe]
[logging.vette]
[domain.template]
# Site-wide domain defaults. To configure an individual
# domain, add a [domain.example_com] section with the overrides.
# This is the host name for the email interface.
email_host: example.com
# This is the base url for the domain's web interface. It must include the
# url scheme.
base_url: http://example.com
# The contact address for this domain. This is advertised as the human to
# contact when users have problems with the lists in this domain.
contact_address: [email protected]
# A short description of this domain.
description: An example domain.
[language.template]
# Template for language definitions. The section name must be [language.xx]
# where xx is the 2-character ISO code for the language.
# The English name for the language.
description: English (USA)
# And the default character set for the language.
charset: us-ascii
# Whether the language is enabled or not.
enable: yes
[language.en]
description: English (USA)
charset: us-ascii
[spam.headers.template]
# This section defines basic header matching actions. Each spam.header
# section names a header to match (case-insensitively), a pattern to match
# against the header's value, and the chain to jump to when the match
# succeeds.
#
# The header value should not include the trailing colon.
header: X-Spam
# The pattern is always matched with re.IGNORECASE.
pattern: xyz
# The chain to jump to if the pattern matches. Maybe be any existing chain
# such as 'discard', 'reject', 'hold', or 'accept'.
chain: hold
......@@ -17,11 +17,11 @@
"""Application support for chain processing."""
__metaclass__ = type
__all__ = [
'initialize',
'process',
]
__metaclass__ = type
from mailman.chains.accept import AcceptChain
......@@ -30,7 +30,7 @@ from mailman.chains.discard import DiscardChain
from mailman.chains.headers import HeaderMatchChain
from mailman.chains.hold import HoldChain
from mailman.chains.reject import RejectChain
from mailman.configuration import config
from mailman.config import config
from mailman.interfaces import LinkAction
......
......@@ -29,8 +29,8 @@ import os
from zope.interface.interface import adapter_hooks
from zope.interface.verify import verifyObject
import mailman.configuration
import mailman.loginit
import mailman.config.config
import mailman.core.logging
from mailman.core.plugins import get_plugin
from mailman.interfaces import IDatabase
......@@ -61,10 +61,10 @@ def initialize_1(config_path, propagate_logs):
# restrictive permissions in order to handle private archives, but it
# handles that correctly.
os.umask(007)
mailman.configuration.config.load(config_path)
mailman.config.config.load(config_path)
# Create the queue and log directories if they don't already exist.
mailman.configuration.config.ensure_directories_exist()
mailman.loginit