summaryrefslogtreecommitdiff
path: root/mailman/archiving/pipermail.py
diff options
context:
space:
mode:
authorBarry Warsaw2009-01-25 13:01:41 -0500
committerBarry Warsaw2009-01-25 13:01:41 -0500
commiteefd06f1b88b8ecbb23a9013cd223b72ca85c20d (patch)
tree72c947fe16fce0e07e996ee74020b26585d7e846 /mailman/archiving/pipermail.py
parent07871212f74498abd56bef3919bf3e029eb8b930 (diff)
downloadmailman-eefd06f1b88b8ecbb23a9013cd223b72ca85c20d.tar.gz
mailman-eefd06f1b88b8ecbb23a9013cd223b72ca85c20d.tar.zst
mailman-eefd06f1b88b8ecbb23a9013cd223b72ca85c20d.zip
Diffstat (limited to 'mailman/archiving/pipermail.py')
-rw-r--r--mailman/archiving/pipermail.py121
1 files changed, 0 insertions, 121 deletions
diff --git a/mailman/archiving/pipermail.py b/mailman/archiving/pipermail.py
deleted file mode 100644
index 377f4ab53..000000000
--- a/mailman/archiving/pipermail.py
+++ /dev/null
@@ -1,121 +0,0 @@
-# Copyright (C) 2007-2009 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
-
-from cStringIO import StringIO
-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:
- url = mlist.script_url('private') + '/index.html'
- else:
- web_host = config.domains[mlist.host_name].url_host
- return expand(config.archiver.pipermail.base_url,
- dict(listname=mlist.fqdn_listname,
- hostname=web_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`."""
- text = str(message)
- fileobj = StringIO(text)
- h = HyperArchive(IPipermailMailingList(mlist))
- h.processUnixMailbox(fileobj)
- h.close()
- fileobj.close()
- # There's no good way to know the url for the archived message.
- return None