summaryrefslogtreecommitdiff
path: root/src/mailman/archiving
diff options
context:
space:
mode:
authorBarry Warsaw2012-03-15 19:06:22 -0700
committerBarry Warsaw2012-03-15 19:06:22 -0700
commit44ec37f890c7d4d35504d8f2e56c01abe8c60940 (patch)
tree1be17a33b6deb243abb7397b5038ede72411614b /src/mailman/archiving
parentbcc42e2201c7172848185e5675a7b79e3d28aa0f (diff)
downloadmailman-44ec37f890c7d4d35504d8f2e56c01abe8c60940.tar.gz
mailman-44ec37f890c7d4d35504d8f2e56c01abe8c60940.tar.zst
mailman-44ec37f890c7d4d35504d8f2e56c01abe8c60940.zip
Eradicate Pipermail. Everything but the scrubber test works. That will take
some new APIs I suspect.
Diffstat (limited to 'src/mailman/archiving')
-rw-r--r--src/mailman/archiving/docs/common.rst43
-rw-r--r--src/mailman/archiving/pipermail.py128
-rw-r--r--src/mailman/archiving/prototype.py2
3 files changed, 13 insertions, 160 deletions
diff --git a/src/mailman/archiving/docs/common.rst b/src/mailman/archiving/docs/common.rst
index 45ec8f194..9a79c3121 100644
--- a/src/mailman/archiving/docs/common.rst
+++ b/src/mailman/archiving/docs/common.rst
@@ -21,7 +21,6 @@ header, and one that provides a *permalink* to the specific message object in
the archive. This latter is appropriate for the message footer or for the RFC
5064 ``Archived-At:`` header.
-Pipermail does not support a permalink, so that interface returns ``None``.
Mailman defines a draft spec for how list servers and archivers can
interoperate.
@@ -38,9 +37,6 @@ interoperate.
mhonarc
http://lists.example.com/.../test@example.com
http://lists.example.com/.../RSZCG7IGPHFIRW3EMTVMMDNJMNCVCOLE
- pipermail
- http://www.example.com/pipermail/test@example.com
- None
prototype
http://lists.example.com
http://lists.example.com/RSZCG7IGPHFIRW3EMTVMMDNJMNCVCOLE
@@ -49,20 +45,8 @@ interoperate.
Sending the message to the archiver
===================================
-The archiver is also able to archive the message.
-::
-
- >>> archivers['pipermail'].archive_message(mlist, msg)
-
- >>> import os
- >>> from mailman.interfaces.archiver import IPipermailMailingList
- >>> pckpath = os.path.join(
- ... IPipermailMailingList(mlist).archive_dir(),
- ... 'pipermail.pck')
- >>> os.path.exists(pckpath)
- True
-
-Note however that the prototype archiver can't archive messages.
+The archiver is also able to archive the message. Note however that the
+prototype archiver can't archive messages.
>>> archivers['prototype'].archive_message(mlist, msg)
Traceback (most recent call last):
@@ -172,20 +156,17 @@ A MHonArc_ archiver is also available.
Messages sent to a local MHonArc instance are added to its archive via a
subprocess call.
+ >>> from mailman.testing.helpers import LogFileMark
+ >>> mark = LogFileMark('mailman.archiver')
>>> archiver.archive_message(mlist, msg)
- >>> archive_log = open(os.path.join(config.LOG_DIR, 'archiver'))
- >>> try:
- ... contents = archive_log.read()
- ... finally:
- ... archive_log.close()
- >>> print 'LOG:', contents
- LOG: ... /usr/bin/mhonarc -add
- -dbfile /.../private/test@example.com.mbox/mhonarc.db
- -outdir /.../mhonarc/test@example.com
- -stderr /.../logs/mhonarc
- -stdout /.../logs/mhonarc
- -spammode -umask 022
- ...
+ >>> print 'LOG:', mark.readline()
+ LOG: ... /usr/bin/mhonarc
+ -add
+ -dbfile .../test@example.com.mbox/mhonarc.db
+ -outdir .../mhonarc/test@example.com
+ -stderr .../logs/mhonarc
+ -stdout .../logs/mhonarc -spammode -umask 022
+
.. _`The Mail Archive`: http://www.mail-archive.com
.. _MHonArc: http://www.mhonarc.org
diff --git a/src/mailman/archiving/pipermail.py b/src/mailman/archiving/pipermail.py
deleted file mode 100644
index 03dcd97f4..000000000
--- a/src/mailman/archiving/pipermail.py
+++ /dev/null
@@ -1,128 +0,0 @@
-# Copyright (C) 2007-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/>.
-
-"""Pipermail archiver."""
-
-from __future__ import absolute_import, unicode_literals
-
-__metaclass__ = type
-__all__ = [
- 'Pipermail',
- ]
-
-
-import os
-import mailbox
-import tempfile
-
-from zope.interface import implements
-from zope.interface.interface import adapter_hooks
-
-from mailman.config import config
-from mailman.interfaces.archiver import IArchiver, IPipermailMailingList
-from mailman.interfaces.mailinglist import IMailingList
-from mailman.utilities.filesystem import makedirs
-from mailman.utilities.string import expand
-
-from mailman.Archiver.HyperArch import HyperArchive
-
-
-
-class PipermailMailingListAdapter:
- """An adapter for MailingList objects to work with Pipermail."""
-
- implements(IPipermailMailingList)
-
- def __init__(self, mlist):
- self._mlist = mlist
-
- def __getattr__(self, name):
- return getattr(self._mlist, name)
-
- def archive_dir(self):
- """See `IPipermailMailingList`."""
- if self._mlist.archive_private:
- basedir = config.PRIVATE_ARCHIVE_FILE_DIR
- else:
- basedir = config.PUBLIC_ARCHIVE_FILE_DIR
- # Make sure the archive directory exists.
- archive_dir = os.path.join(basedir, self._mlist.fqdn_listname)
- makedirs(archive_dir)
- return archive_dir
-
-
-def adapt_mailing_list_for_pipermail(iface, obj):
- """Adapt `IMailingLists` to `IPipermailMailingList`.
-
- :param iface: The interface to adapt to.
- :type iface: `zope.interface.Interface`
- :param obj: The object being adapted.
- :type obj: any object
- :return: An `IPipermailMailingList` instance if adaptation succeeded or
- None if it didn't.
- """
- return (PipermailMailingListAdapter(obj)
- if IMailingList.providedBy(obj) and iface is IPipermailMailingList
- else None)
-
-adapter_hooks.append(adapt_mailing_list_for_pipermail)
-
-
-
-class Pipermail:
- """The stock Pipermail archiver."""
-
- implements(IArchiver)
-
- name = 'pipermail'
-
- @staticmethod
- def list_url(mlist):
- """See `IArchiver`."""
- if mlist.archive_private:
- return mlist.script_url('private') + '/index.html'
- else:
- return expand(config.archiver.pipermail.base_url,
- dict(listname=mlist.fqdn_listname,
- hostname=mlist.domain.url_host,
- fqdn_listname=mlist.fqdn_listname,
- ))
-
- @staticmethod
- def permalink(mlist, message):
- """See `IArchiver`."""
- # Not currently implemented.
- return None
-
- @staticmethod
- def archive_message(mlist, message):
- """See `IArchiver`."""
- fd, path = tempfile.mkstemp('.mbox')
- os.close(fd)
- try:
- mbox = mailbox.mbox(path, create=True)
- mbox.add(message)
- finally:
- mbox.close()
- h = HyperArchive(IPipermailMailingList(mlist))
- try:
- h.processUnixMailbox(path)
- finally:
- h.close()
- os.remove(path)
- # There's no good way to know the url for the archived message.
- return None
diff --git a/src/mailman/archiving/prototype.py b/src/mailman/archiving/prototype.py
index 55d78074e..f041d4450 100644
--- a/src/mailman/archiving/prototype.py
+++ b/src/mailman/archiving/prototype.py
@@ -60,6 +60,6 @@ class Prototype:
return urljoin(Prototype.list_url(mlist), message_id_hash)
@staticmethod
- def archive_message(mlist, message):
+ def archive_message(mlist, msg):
"""See `IArchiver`."""
raise NotImplementedError