diff options
| author | Barry Warsaw | 2008-07-10 22:23:52 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2008-07-10 22:23:52 -0400 |
| commit | 61e99148ab4052f00951e72e19b3a750ef1e4739 (patch) | |
| tree | 06ffed62dc4ffb55ef1036f02268dee5a0aa6847 /mailman/app | |
| parent | 408043ad8404798e9b8b93a1ee1cd81db897639c (diff) | |
| parent | 82de03b4699cb9e841f4196ff7c92e043056d3e3 (diff) | |
| download | mailman-61e99148ab4052f00951e72e19b3a750ef1e4739.tar.gz mailman-61e99148ab4052f00951e72e19b3a750ef1e4739.tar.zst mailman-61e99148ab4052f00951e72e19b3a750ef1e4739.zip | |
Merging the Mail-Archive.com branch.
Diffstat (limited to 'mailman/app')
| -rw-r--r-- | mailman/app/archiving.py | 154 |
1 files changed, 0 insertions, 154 deletions
diff --git a/mailman/app/archiving.py b/mailman/app/archiving.py deleted file mode 100644 index 15e987daf..000000000 --- a/mailman/app/archiving.py +++ /dev/null @@ -1,154 +0,0 @@ -# Copyright (C) 2007-2008 by the Free Software Foundation, Inc. -# -# This program 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 2 -# of the License, or (at your option) any later version. -# -# This program 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 this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -# USA. - -"""Application level archiving support.""" - -__metaclass__ = type -__all__ = [ - 'Pipermail', - 'Prototype', - ] - - -import os -import hashlib - -from base64 import b32encode -from cStringIO import StringIO -from email.utils import make_msgid -from string import Template -from urlparse import urljoin -from zope.interface import implements -from zope.interface.interface import adapter_hooks - -from mailman.configuration import config -from mailman.interfaces.archiver import IArchiver, IPipermailMailingList -from mailman.interfaces.mailinglist import IMailingList - -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 - return os.path.join(basedir, self._mlist.fqdn_listname) - - -def adapt_mailing_list_for_pipermail(iface, obj): - """Adapt IMailingLists to IPipermailMailingList.""" - if IMailingList.providedBy(obj) and iface is IPipermailMailingList: - return PipermailMailingListAdapter(obj) - return None - -adapter_hooks.append(adapt_mailing_list_for_pipermail) - - - -class Pipermail: - """The stock Pipermail archiver.""" - - implements(IArchiver) - - name = 'pipermail' - is_enabled = True - - @staticmethod - def list_url(mlist): - """See `IArchiver`.""" - if mlist.archive_private: - url = mlist.script_url('private') + '/index.html' - else: - web_host = config.domains.get(mlist.host_name, mlist.host_name) - url = Template(config.PUBLIC_ARCHIVE_URL).safe_substitute( - listname=mlist.fqdn_listname, - hostname=web_host, - fqdn_listname=mlist.fqdn_listname, - ) - return url - - @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 - - - -class Prototype: - """A prototype of a third party archiver. - - Mailman proposes a draft specification for interoperability between list - servers and archivers: <http://wiki.list.org/display/DEV/Stable+URLs>. - """ - - implements(IArchiver) - - name = 'prototype' - is_enabled = False - - @staticmethod - def list_url(mlist): - """See `IArchiver`.""" - web_host = config.domains.get(mlist.host_name, mlist.host_name) - return 'http://' + web_host - - @staticmethod - def permalink(mlist, msg): - """See `IArchiver`.""" - message_id = msg.get('message-id') - # It is not the archiver's job to ensure the message has a Message-ID. - assert message_id is not None, 'No Message-ID found' - # The angle brackets are not part of the Message-ID. See RFC 2822. - if message_id.startswith('<') and message_id.endswith('>'): - message_id = message_id[1:-1] - digest = hashlib.sha1(message_id).digest() - message_id_hash = b32encode(digest) - del msg['x-message-id-hash'] - msg['X-Message-ID-Hash'] = message_id_hash - return urljoin(Prototype.list_url(mlist), message_id_hash) - - @staticmethod - def archive_message(mlist, message): - """See `IArchiver`.""" - raise NotImplementedError |
