summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarry Warsaw2012-11-04 16:31:00 -0500
committerBarry Warsaw2012-11-04 16:31:00 -0500
commit7caa62a470b4b4239aca136803ad04ad8193a175 (patch)
tree47bbecabb8c2d1165ffbc8cecfe043dc23b99f1c
parent89f6e779db51478ea95b71f2ad3dc9d7f5f51e05 (diff)
parentfa7e38b649dba0c0b920c94ad001c0ae136a86e8 (diff)
downloadmailman-7caa62a470b4b4239aca136803ad04ad8193a175.tar.gz
mailman-7caa62a470b4b4239aca136803ad04ad8193a175.tar.zst
mailman-7caa62a470b4b4239aca136803ad04ad8193a175.zip
-rw-r--r--src/mailman/archiving/mailarchive.py24
-rw-r--r--src/mailman/archiving/mhonarc.py23
-rw-r--r--src/mailman/config/mail_archive.cfg29
-rw-r--r--src/mailman/config/mhonarc.cfg27
-rw-r--r--src/mailman/config/schema.cfg24
-rw-r--r--src/mailman/docs/ACKNOWLEDGMENTS.rst1
-rw-r--r--src/mailman/testing/mail_archive.cfg4
-rw-r--r--src/mailman/testing/mhonarc.cfg4
-rw-r--r--src/mailman/testing/testing.cfg5
9 files changed, 104 insertions, 37 deletions
diff --git a/src/mailman/archiving/mailarchive.py b/src/mailman/archiving/mailarchive.py
index e61683a09..bbd3d5ce0 100644
--- a/src/mailman/archiving/mailarchive.py
+++ b/src/mailman/archiving/mailarchive.py
@@ -30,6 +30,7 @@ from urlparse import urljoin
from zope.interface import implementer
from mailman.config import config
+from mailman.config.config import external_configuration
from mailman.interfaces.archiver import ArchivePolicy, IArchiver
@@ -43,16 +44,20 @@ class MailArchive:
name = 'mail-archive'
- @staticmethod
- def list_url(mlist):
+ def __init__(self):
+ # Read our specific configuration file
+ archiver_config = external_configuration(
+ config.archiver.mail_archive.configuration)
+ self.base_url = archiver_config.get('general', 'base_url')
+ self.recipient = archiver_config.get('general', 'recipient')
+
+ def list_url(self, mlist):
"""See `IArchiver`."""
if mlist.archive_policy is ArchivePolicy.public:
- return urljoin(config.archiver.mail_archive.base_url,
- quote(mlist.posting_address))
+ return urljoin(self.base_url, quote(mlist.posting_address))
return None
- @staticmethod
- def permalink(mlist, msg):
+ def permalink(self, mlist, msg):
"""See `IArchiver`."""
if mlist.archive_policy is not ArchivePolicy.public:
return None
@@ -62,13 +67,12 @@ class MailArchive:
message_id_hash = msg.get('x-message-id-hash')
if message_id_hash is None:
return None
- return urljoin(config.archiver.mail_archive.base_url, message_id_hash)
+ return urljoin(self.base_url, message_id_hash)
- @staticmethod
- def archive_message(mlist, msg):
+ def archive_message(self, mlist, msg):
"""See `IArchiver`."""
if mlist.archive_policy is ArchivePolicy.public:
config.switchboards['out'].enqueue(
msg,
listname=mlist.fqdn_listname,
- recipients=[config.archiver.mail_archive.recipient])
+ recipients=[self.recipient])
diff --git a/src/mailman/archiving/mhonarc.py b/src/mailman/archiving/mhonarc.py
index 7f0af6cd6..06119ae35 100644
--- a/src/mailman/archiving/mhonarc.py
+++ b/src/mailman/archiving/mhonarc.py
@@ -32,6 +32,7 @@ from urlparse import urljoin
from zope.interface import implementer
from mailman.config import config
+from mailman.config.config import external_configuration
from mailman.interfaces.archiver import IArchiver
from mailman.utilities.string import expand
@@ -46,18 +47,23 @@ class MHonArc:
name = 'mhonarc'
- @staticmethod
- def list_url(mlist):
+ def __init__(self):
+ # Read our specific configuration file
+ archiver_config = external_configuration(
+ config.archiver.mhonarc.configuration)
+ self.base_url = archiver_config.get('general', 'base_url')
+ self.command = archiver_config.get('general', 'command')
+
+ def list_url(self, mlist):
"""See `IArchiver`."""
# XXX What about private MHonArc archives?
- return expand(config.archiver.mhonarc.base_url,
+ return expand(self.base_url,
dict(listname=mlist.fqdn_listname,
hostname=mlist.domain.url_host,
fqdn_listname=mlist.fqdn_listname,
))
- @staticmethod
- def permalink(mlist, msg):
+ def permalink(self, mlist, msg):
"""See `IArchiver`."""
# XXX What about private MHonArc archives?
# It is the LMTP server's responsibility to ensure that the message
@@ -66,14 +72,13 @@ class MHonArc:
message_id_hash = msg.get('x-message-id-hash')
if message_id_hash is None:
return None
- return urljoin(MHonArc.list_url(mlist), message_id_hash)
+ return urljoin(self.list_url(mlist), message_id_hash)
- @staticmethod
- def archive_message(mlist, msg):
+ def archive_message(self, mlist, msg):
"""See `IArchiver`."""
substitutions = config.__dict__.copy()
substitutions['listname'] = mlist.fqdn_listname
- command = expand(config.archiver.mhonarc.command, substitutions)
+ command = expand(self.command, substitutions)
proc = subprocess.Popen(
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
shell=True)
diff --git a/src/mailman/config/mail_archive.cfg b/src/mailman/config/mail_archive.cfg
new file mode 100644
index 000000000..ee8430317
--- /dev/null
+++ b/src/mailman/config/mail_archive.cfg
@@ -0,0 +1,29 @@
+# Copyright (C) 2008-2012 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 configuration file for the mail-archive.com archiver
+
+[general]
+# The base url for the archiver. This is used to to calculate links to
+# individual messages in the archive.
+base_url: http://www.mail-archive.com/
+
+# If the archiver works by getting a copy of the message, this is the address
+# to send the copy to.
+#
+# See: http://www.mail-archive.com/faq.html#newlist
+recipient: archive@mail-archive.com
diff --git a/src/mailman/config/mhonarc.cfg b/src/mailman/config/mhonarc.cfg
new file mode 100644
index 000000000..310c3d471
--- /dev/null
+++ b/src/mailman/config/mhonarc.cfg
@@ -0,0 +1,27 @@
+# Copyright (C) 2008-2012 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 configuration file for the MHonArc archiver
+
+[general]
+# The base url for the archiver. This is used to to calculate links to
+# individual messages in the archive.
+base_url: http://$hostname/archives/$fqdn_listname
+
+# If the archiver works by calling a command on the local machine, this is the
+# command to call.
+command: /usr/bin/mhonarc -outdir /path/to/archive/$listname -add
diff --git a/src/mailman/config/schema.cfg b/src/mailman/config/schema.cfg
index 4e454fc86..37322418a 100644
--- a/src/mailman/config/schema.cfg
+++ b/src/mailman/config/schema.cfg
@@ -537,17 +537,13 @@ class: mailman.archiving.prototype.Prototype
# Set this to 'yes' to enable the archiver.
enable: no
-# The base url for the archiver. This is used to to calculate links to
-# individual messages in the archive.
-base_url: http://archive.example.com/
-
-# If the archiver works by getting a copy of the message, this is the address
-# to send the copy to.
-recipient: archive@archive.example.com
-
-# If the archiver works by calling a command on the local machine, this is the
-# command to call.
-command: /bin/echo
+# Additional configuration for the archiver. The path can be either a file
+# system path or a Python import path. If the value starts with python: then
+# it is a Python import path, otherwise it is a file system path. File system
+# paths must be absolute since no guarantees are made about the current
+# working directory. Python paths should not include the trailing .cfg, which
+# the file must end with.
+configuration: changeme
# When sending the message to the archiver, you have the option of
# "clobbering" the Date: header, specifically to make it more sane. Some
@@ -569,14 +565,12 @@ clobber_skew: 1d
[archiver.mhonarc]
# This is the stock MHonArc archiver.
class: mailman.archiving.mhonarc.MHonArc
-
-base_url: http://$hostname/archives/$fqdn_listname
-
+configuration: python:mailman.config.mhonarc
[archiver.mail_archive]
# This is the stock mail-archive.com archiver.
class: mailman.archiving.mailarchive.MailArchive
-
+configuration: python:mailman.config.mail_archive
[archiver.prototype]
# This is a prototypical sample archiver.
diff --git a/src/mailman/docs/ACKNOWLEDGMENTS.rst b/src/mailman/docs/ACKNOWLEDGMENTS.rst
index 10d4bcd93..c0ef13a22 100644
--- a/src/mailman/docs/ACKNOWLEDGMENTS.rst
+++ b/src/mailman/docs/ACKNOWLEDGMENTS.rst
@@ -101,6 +101,7 @@ left off the list!
* Stuart Bishop
* David Blomquist
* Bojan
+* Aurélien Bompard
* Søren Bondrup
* Grant Bowman
* Alessio Bragadini
diff --git a/src/mailman/testing/mail_archive.cfg b/src/mailman/testing/mail_archive.cfg
new file mode 100644
index 000000000..0011781ba
--- /dev/null
+++ b/src/mailman/testing/mail_archive.cfg
@@ -0,0 +1,4 @@
+[general]
+base_url: http://go.mail-archive.dev/
+
+recipient: archive@mail-archive.dev
diff --git a/src/mailman/testing/mhonarc.cfg b/src/mailman/testing/mhonarc.cfg
new file mode 100644
index 000000000..11a15eef3
--- /dev/null
+++ b/src/mailman/testing/mhonarc.cfg
@@ -0,0 +1,4 @@
+[general]
+base_url: http://$hostname/archives/$fqdn_listname
+
+command: /bin/echo "/usr/bin/mhonarc -add -dbfile $PRIVATE_ARCHIVE_FILE_DIR/${listname}.mbox/mhonarc.db -outdir $VAR_DIR/mhonarc/${listname} -stderr $LOG_DIR/mhonarc -stdout $LOG_DIR/mhonarc -spammode -umask 022"
diff --git a/src/mailman/testing/testing.cfg b/src/mailman/testing/testing.cfg
index 7d57aa681..85b284cfe 100644
--- a/src/mailman/testing/testing.cfg
+++ b/src/mailman/testing/testing.cfg
@@ -74,12 +74,11 @@ enable: yes
[archiver.mail_archive]
enable: yes
-base_url: http://go.mail-archive.dev/
-recipient: archive@mail-archive.dev
+configuration: python:mailman.testing.mail_archive
[archiver.mhonarc]
enable: yes
-command: /bin/echo "/usr/bin/mhonarc -add -dbfile $PRIVATE_ARCHIVE_FILE_DIR/${listname}.mbox/mhonarc.db -outdir $VAR_DIR/mhonarc/${listname} -stderr $LOG_DIR/mhonarc -stdout $LOG_DIR/mhonarc -spammode -umask 022"
+configuration: python:mailman.testing.mhonarc
[language.ja]
description: Japanese