Aurélien Bompard has proposed merging lp:~abompard/mailman/extconfig into
lp:mailman.
Requested reviews:
Mailman Coders (mailman-coders)
For more details, see:
https://code.launchpad.net/~abompard/mailman/extconfig/+merge/124729
This is the changed proposed on the devel mailing-list here:
http://mail.python.org/pipermail/mailman-developers/2012-September/022438.html
--
https://code.launchpad.net/~abompard/mailman/extconfig/+merge/124729
Your team Mailman Coders is requested to review the proposed merge of
lp:~abompard/mailman/extconfig into lp:mailman.
=== modified file 'src/mailman/archiving/mailarchive.py'
--- src/mailman/archiving/mailarchive.py 2012-08-18 23:32:53 +0000
+++ src/mailman/archiving/mailarchive.py 2012-09-17 16:02:19 +0000
@@ -43,16 +43,25 @@
name = 'mail-archive'
- @staticmethod
- def list_url(mlist):
+ def __init__(self):
+ # Read our specific configuration file
+ self.config = config.archiver_config("mail_archive")
+
+ def list_url(self, mlist):
"""See `IArchiver`."""
+<<<<<<< TREE
if mlist.archive_policy is ArchivePolicy.public:
return urljoin(config.archiver.mail_archive.base_url,
quote(mlist.posting_address))
return None
+=======
+ if mlist.archive_private:
+ return None
+ return urljoin(self.config.get("general", "base_url"),
+ quote(mlist.posting_address))
+>>>>>>> MERGE-SOURCE
- @staticmethod
- def permalink(mlist, msg):
+ def permalink(self, mlist, msg):
"""See `IArchiver`."""
if mlist.archive_policy is not ArchivePolicy.public:
return None
@@ -62,13 +71,12 @@
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.config.get("general", "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.config.get("general", "recipient")])
=== modified file 'src/mailman/archiving/mhonarc.py'
--- src/mailman/archiving/mhonarc.py 2012-04-26 02:08:22 +0000
+++ src/mailman/archiving/mhonarc.py 2012-09-17 16:02:19 +0000
@@ -46,18 +46,20 @@
name = 'mhonarc'
- @staticmethod
- def list_url(mlist):
+ def __init__(self):
+ # Read our specific configuration file
+ self.config = config.archiver_config("mhonarc")
+
+ def list_url(self, mlist):
"""See `IArchiver`."""
# XXX What about private MHonArc archives?
- return expand(config.archiver.mhonarc.base_url,
+ return expand(self.config.get("general", "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 +68,13 @@
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.config.get("general", "command"), substitutions)
proc = subprocess.Popen(
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
shell=True)
=== modified file 'src/mailman/config/config.py'
--- src/mailman/config/config.py 2012-07-02 20:56:35 +0000
+++ src/mailman/config/config.py 2012-09-17 16:02:19 +0000
@@ -27,9 +27,10 @@
import os
import sys
+from ConfigParser import SafeConfigParser
from lazr.config import ConfigSchema, as_boolean
-from pkg_resources import resource_stream
+from pkg_resources import resource_stream, resource_exists
from string import Template
from zope.component import getUtility
from zope.event import notify
@@ -235,3 +236,31 @@
"""Iterate over all the language configuration sections."""
for section in self._config.getByCategory('language', []):
yield section
+
+ def get_additional_config(self, name, keyname):
+ """Return an external ini-file as specified by the keyname."""
+ add_config = SafeConfigParser()
+ if resource_exists('mailman.config', '%s.cfg' % name):
+ included_config_file = resource_stream('mailman.config',
+ '%s.cfg' % name)
+ add_config.readfp(included_config_file)
+ # Resolve the path value from the key name
+ path = self._config
+ for key in keyname.split("."):
+ path = getattr(path, key)
+ # Load the file
+ configured_path = os.path.expanduser(path) # TODO: allow URLs
+ if not configured_path.startswith("/"):
+ # Consider it relative to the mailman.cfg file
+ for overlay in self.overlays:
+ if os.sep in overlay.filename:
+ configured_path = os.path.join(
+ os.path.dirname(overlay.filename),
+ configured_path)
+ break
+ r = add_config.read([configured_path])
+ return add_config
+
+ def archiver_config(self, name):
+ """A shortcut to self.get_additional_config() for achivers."""
+ return self.get_additional_config(name, "archiver.%s.configure" % name)
=== added file 'src/mailman/config/mail_archive.cfg'
--- src/mailman/config/mail_archive.cfg 1970-01-01 00:00:00 +0000
+++ src/mailman/config/mail_archive.cfg 2012-09-17 16:02:19 +0000
@@ -0,0 +1,28 @@
+# 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: [email protected]
=== added file 'src/mailman/config/mhonarc.cfg'
--- src/mailman/config/mhonarc.cfg 1970-01-01 00:00:00 +0000
+++ src/mailman/config/mhonarc.cfg 2012-09-17 16:02:19 +0000
@@ -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
=== modified file 'src/mailman/config/schema.cfg'
--- src/mailman/config/schema.cfg 2012-08-16 01:08:39 +0000
+++ src/mailman/config/schema.cfg 2012-09-17 16:02:19 +0000
@@ -535,17 +535,8 @@
# 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: [email protected]
-
-# 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.
+configure: /path/to/file.cfg
# When sending the message to the archiver, you have the option of
# "clobbering" the Date: header, specifically to make it more sane. Some
@@ -564,17 +555,20 @@
clobber_date: maybe
clobber_skew: 1d
+
[archiver.mhonarc]
# This is the stock MHonArc archiver.
class: mailman.archiving.mhonarc.MHonArc
-base_url: http://$hostname/archives/$fqdn_listname
+configure: $ext_dir/mhonarc.cfg
[archiver.mail_archive]
# This is the stock mail-archive.com archiver.
class: mailman.archiving.mailarchive.MailArchive
+configure: $ext_dir/mail_archive.cfg
+
[archiver.prototype]
# This is a prototypical sample archiver.
_______________________________________________
Mailman-coders mailing list
[email protected]
http://mail.python.org/mailman/listinfo/mailman-coders