diff options
| author | Barry Warsaw | 2008-01-13 16:17:38 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2008-01-13 16:17:38 -0500 |
| commit | 0d0c030d50e4dbd11f33ccddb96cf13fd3470cd2 (patch) | |
| tree | 4e182668a895beabcb35a7659c37ac2fb04ca5bf /Mailman/app | |
| parent | 90355248db6f6619148abb2a9137c3a564345729 (diff) | |
| download | mailman-0d0c030d50e4dbd11f33ccddb96cf13fd3470cd2.tar.gz mailman-0d0c030d50e4dbd11f33ccddb96cf13fd3470cd2.tar.zst mailman-0d0c030d50e4dbd11f33ccddb96cf13fd3470cd2.zip | |
Add an interface IArchiver which is used to calculate urls and send messages
to the archiver. Also add a plugin architecture for easily overriding the
archiver, and hook this into the setup.py script.
Updated CookHeaders.py and Scrubber.py handlers to use the plugged archiver.
Updated doctests as appropriate.
Fix a typo in the setup.py file.
Diffstat (limited to 'Mailman/app')
| -rw-r--r-- | Mailman/app/archiving.py | 65 |
1 files changed, 53 insertions, 12 deletions
diff --git a/Mailman/app/archiving.py b/Mailman/app/archiving.py index 6ab3479eb..5e118b0f9 100644 --- a/Mailman/app/archiving.py +++ b/Mailman/app/archiving.py @@ -1,4 +1,4 @@ -# Copyright (C) 2007 by the Free Software Foundation, Inc. +# 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 @@ -17,20 +17,61 @@ """Application level archiving support.""" +__all__ = [ + 'StockArchiver', + 'get_archiver', + ] +__metaclass__ = type + + from string import Template +from zope.interface import implements +from zope.interface.verify import verifyObject +from Mailman.app.plugins import get_plugin from Mailman.configuration import config +from Mailman.interfaces import IArchiver -def get_base_archive_url(mlist): - 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 +class StockArchiver: + """The stock Pipermail archiver.""" + + implements(IArchiver) + + def get_list_url(self, 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 + + def get_message_url(self, mlist, message): + """See `IArchiver`.""" + # Not currently implemented. + return None + + def archive_message(self, mlist, message): + """See `IArchiver`.""" + return None + + + +_archiver = None + +def get_archiver(): + """Return the currently registered global archiver. + + Uses the plugin architecture to find the IArchiver instance. + """ + global _archiver + if _archiver is None: + _archiver = get_plugin('mailman.archiver')() + verifyObject(IArchiver, _archiver) + return _archiver |
