summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarry Warsaw2008-06-15 00:01:55 -0400
committerBarry Warsaw2008-06-15 00:01:55 -0400
commitee349897c99a75da4da4698c64bee8cd0d743d97 (patch)
treee2b00e3c9eb399d8dd77d6a60a30a996af57ed44
parent67e437883d520bf7ea78ae55235892aa946ef0b4 (diff)
parent3d192123461559445bd7e68ef163828bb51852e6 (diff)
downloadmailman-ee349897c99a75da4da4698c64bee8cd0d743d97.tar.gz
mailman-ee349897c99a75da4da4698c64bee8cd0d743d97.tar.zst
mailman-ee349897c99a75da4da4698c64bee8cd0d743d97.zip
-rw-r--r--mailman/app/archiving.py41
-rw-r--r--mailman/interfaces/archiver.py7
-rw-r--r--mailman/pipeline/cook_headers.py23
-rw-r--r--mailman/pipeline/docs/archives.txt6
-rw-r--r--mailman/pipeline/scrubber.py4
-rw-r--r--mailman/queue/archive.py3
-rw-r--r--setup.py3
7 files changed, 31 insertions, 56 deletions
diff --git a/mailman/app/archiving.py b/mailman/app/archiving.py
index c790bc3dc..5a752063d 100644
--- a/mailman/app/archiving.py
+++ b/mailman/app/archiving.py
@@ -20,18 +20,14 @@
__metaclass__ = type
__all__ = [
'Pipermail',
- 'get_primary_archiver',
]
import os
-import pkg_resources
from string import Template
from zope.interface import implements
-from zope.interface.verify import verifyObject
-from mailman.app.plugins import get_plugins
from mailman.configuration import config
from mailman.interfaces import IArchiver
@@ -64,47 +60,34 @@ class Pipermail:
implements(IArchiver)
- def __init__(self, mlist):
- self._mlist = mlist
-
- def get_list_url(self):
+ @staticmethod
+ def list_url(mlist):
"""See `IArchiver`."""
- if self._mlist.archive_private:
- url = self._mlist.script_url('private') + '/index.html'
+ if mlist.archive_private:
+ url = mlist.script_url('private') + '/index.html'
else:
- web_host = config.domains.get(
- self._mlist.host_name, self._mlist.host_name)
+ web_host = config.domains.get(mlist.host_name, mlist.host_name)
url = Template(config.PUBLIC_ARCHIVE_URL).safe_substitute(
- listname=self._mlist.fqdn_listname,
+ listname=mlist.fqdn_listname,
hostname=web_host,
- fqdn_listname=self._mlist.fqdn_listname,
+ fqdn_listname=mlist.fqdn_listname,
)
return url
- def get_message_url(self, message):
+ @staticmethod
+ def permalink(mlist, message):
"""See `IArchiver`."""
# Not currently implemented.
return None
- def archive_message(self, message):
+ @staticmethod
+ def archive_message(mlist, message):
"""See `IArchiver`."""
text = str(message)
fileobj = StringIO(text)
- h = HyperArchive(PipermailMailingListAdapter(self._mlist))
+ h = HyperArchive(PipermailMailingListAdapter(mlist))
h.processUnixMailbox(fileobj)
h.close()
fileobj.close()
# There's no good way to know the url for the archived message.
return None
-
-
-
-def get_primary_archiver(mlist):
- """Return the primary archiver."""
- entry_points = list(pkg_resources.iter_entry_points('mailman.archiver'))
- if len(entry_points) == 0:
- return None
- for ep in entry_points:
- if ep.name == 'default':
- return ep.load()(mlist)
- return None
diff --git a/mailman/interfaces/archiver.py b/mailman/interfaces/archiver.py
index 3b96c5c53..40b05b76c 100644
--- a/mailman/interfaces/archiver.py
+++ b/mailman/interfaces/archiver.py
@@ -24,14 +24,14 @@ from zope.interface import Interface, Attribute
class IArchiver(Interface):
"""An interface to the archiver."""
- def get_list_url(mlist):
+ def list_url(mlist):
"""Return the url to the top of the list's archive.
:param mlist: The IMailingList object.
:returns: The url string.
"""
- def get_message_url(mlist, message):
+ def permalink(mlist, message):
"""Return the url to the message in the archive.
This url points directly to the message in the archive. This method
@@ -46,9 +46,6 @@ class IArchiver(Interface):
def archive_message(mlist, message):
"""Send the message to the archiver.
- This uses `get_message_url()` to calculate and return the url to the
- message in the archives.
-
:param mlist: The IMailingList object.
:param message: The message object.
:returns: The url string or None if the message's archive url cannot
diff --git a/mailman/pipeline/cook_headers.py b/mailman/pipeline/cook_headers.py
index c237c171a..4cda42c81 100644
--- a/mailman/pipeline/cook_headers.py
+++ b/mailman/pipeline/cook_headers.py
@@ -30,7 +30,7 @@ from email.Utils import parseaddr, formataddr, getaddresses
from zope.interface import implements
from mailman import Utils
-from mailman.app.archiving import get_primary_archiver
+from mailman.app.plugins import get_plugins
from mailman.configuration import config
from mailman.i18n import _
from mailman.interfaces import IHandler, Personalization, ReplyToMunging
@@ -206,29 +206,24 @@ def process(mlist, msg, msgdata):
'List-Unsubscribe': subfieldfmt % (listinfo, mlist.leave_address),
'List-Subscribe' : subfieldfmt % (listinfo, mlist.join_address),
})
- archiver = get_primary_archiver(mlist)
if msgdata.get('reduced_list_headers'):
headers['X-List-Administrivia'] = 'yes'
else:
# List-Post: is controlled by a separate attribute
if mlist.include_list_post_header:
headers['List-Post'] = '<mailto:%s>' % mlist.posting_address
- # Add this header if we're archiving
+ # Add RFC 2369 and 5064 archiving headers, if archiving is enabled.
if mlist.archive:
- archiveurl = archiver.get_list_url()
- headers['List-Archive'] = '<%s>' % archiveurl
+ for archiver in get_plugins('mailman.archiver'):
+ headers['List-Archive'] = '<%s>' % archiver.list_url(mlist)
+ permalink = archiver.permalink(mlist, msg)
+ if permalink is not None:
+ headers['Archived-At'] = permalink
# XXX RFC 2369 also defines a List-Owner header which we are not currently
# supporting, but should.
- #
- # Draft RFC 5064 defines an Archived-At header which contains the pointer
- # directly to the message in the archive. If the currently defined
- # archiver can tell us the URL, go ahead and include this header.
- archived_at = archiver.get_message_url(msg)
- if archived_at is not None:
- headers['Archived-At'] = archived_at
- # First we delete any pre-existing headers because the RFC permits only
- # one copy of each, and we want to be sure it's ours.
for h, v in headers.items():
+ # First we delete any pre-existing headers because the RFC permits
+ # only one copy of each, and we want to be sure it's ours.
del msg[h]
# Wrap these lines if they are too long. 78 character width probably
# shouldn't be hardcoded, but is at least text-MUA friendly. The
diff --git a/mailman/pipeline/docs/archives.txt b/mailman/pipeline/docs/archives.txt
index b7b54f17f..67ad45c89 100644
--- a/mailman/pipeline/docs/archives.txt
+++ b/mailman/pipeline/docs/archives.txt
@@ -7,11 +7,11 @@ delivery processes while messages are archived. This also allows external
archivers to work in a separate process from the main Mailman delivery
processes.
- >>> from mailman.queue import Switchboard
+ >>> from mailman.app.lifecycle import create_list
>>> from mailman.configuration import config
+ >>> from mailman.queue import Switchboard
>>> handler = config.handlers['to-archive']
- >>> mlist = config.db.list_manager.create(u'_xtest@example.com')
- >>> mlist.preferred_language = u'en'
+ >>> mlist = create_list(u'_xtest@example.com')
>>> switchboard = Switchboard(config.ARCHQUEUE_DIR)
A helper function.
diff --git a/mailman/pipeline/scrubber.py b/mailman/pipeline/scrubber.py
index ca1fa37e0..bf6effd3a 100644
--- a/mailman/pipeline/scrubber.py
+++ b/mailman/pipeline/scrubber.py
@@ -40,7 +40,7 @@ from zope.interface import implements
from mailman import Utils
from mailman.Errors import DiscardMessage
-from mailman.app.archiving import get_primary_archiver
+from mailman.app.plugins import get_plugin
from mailman.configuration import config
from mailman.i18n import _
from mailman.interfaces import IHandler
@@ -497,7 +497,7 @@ def save_attachment(mlist, msg, dir, filter_html=True):
fp.write(decodedpayload)
fp.close()
# Now calculate the url to the list's archive.
- baseurl = get_primary_archiver(mlist).get_list_url()
+ baseurl = get_plugin('mailman.scrubber').list_url(mlist)
if not baseurl.endswith('/'):
baseurl += '/'
# Trailing space will definitely be a problem with format=flowed.
diff --git a/mailman/queue/archive.py b/mailman/queue/archive.py
index 52e73d9c8..c24d9478d 100644
--- a/mailman/queue/archive.py
+++ b/mailman/queue/archive.py
@@ -80,6 +80,5 @@ class ArchiveRunner(Runner):
# While a list archiving lock is acquired, archive the message.
with Lock(os.path.join(mlist.data_path, 'archive.lck')):
for archive_factory in get_plugins('mailman.archiver'):
- archiver = archive_factory(mlist)
- archiver.archive_message(msg)
+ archive_factory().archive_message(mlist, msg)
diff --git a/setup.py b/setup.py
index 36f13e716..91dc0b663 100644
--- a/setup.py
+++ b/setup.py
@@ -90,7 +90,8 @@ Any other spelling is incorrect.""",
entry_points = {
'console_scripts': list(scripts),
# Entry point for plugging in different database backends.
- 'mailman.archiver' : 'default = mailman.app.archiving:Pipermail',
+ 'mailman.archiver' : 'pipermail = mailman.app.archiving:Pipermail',
+ 'mailman.scrubber' : 'stock = mailman.app.archiving:Pipermail',
'mailman.commands' : list(commands),
'mailman.database' : 'stock = mailman.database:StockDatabase',
'mailman.mta' : 'stock = mailman.MTA:Manual',