summaryrefslogtreecommitdiff
path: root/Mailman/pipeline/decorate.py
diff options
context:
space:
mode:
authorBarry Warsaw2008-02-17 17:34:21 -0500
committerBarry Warsaw2008-02-17 17:34:21 -0500
commit69d158b13ae9cfa37040c2e7a664ca266b42050b (patch)
tree07f48ee990b6bab514f86199eaa250a04280120c /Mailman/pipeline/decorate.py
parentb36de8a6a5b84021c003b728274f7e9e95861c9d (diff)
downloadmailman-69d158b13ae9cfa37040c2e7a664ca266b42050b.tar.gz
mailman-69d158b13ae9cfa37040c2e7a664ca266b42050b.tar.zst
mailman-69d158b13ae9cfa37040c2e7a664ca266b42050b.zip
Reorganize the Handler architecture to a pipeline architecture with plugins.
Now plugins can define additional handlers and the handlers can be organized into named pipelines. Modules are no longer the unit of a handler, now we use classes so we can assert interface conformance. The GLOBAL_PIPELINE is gone, replaced by the 'built-in' pipeline. The OWNER_PIPELINE is not yet replaced. I still need a few more tests of the basic pipeline architecture, although the individual handlers have pretty good coverage. Added the IHandler and IPipeline interfaces. Still broken, but not yet removed: Mailman/pipeline/moderate.py.
Diffstat (limited to 'Mailman/pipeline/decorate.py')
-rw-r--r--Mailman/pipeline/decorate.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/Mailman/pipeline/decorate.py b/Mailman/pipeline/decorate.py
index f4b6551e3..c7ecb431a 100644
--- a/Mailman/pipeline/decorate.py
+++ b/Mailman/pipeline/decorate.py
@@ -17,17 +17,24 @@
"""Decorate a message by sticking the header and footer around it."""
+__metaclass__ = type
+__all__ = ['Decorate']
+
+
import re
import logging
from email.MIMEText import MIMEText
from string import Template
+from zope.interface import implements
from Mailman import Errors
from Mailman import Utils
from Mailman.Message import Message
from Mailman.configuration import config
from Mailman.i18n import _
+from Mailman.interfaces import IHandler
+
log = logging.getLogger('mailman.error')
@@ -205,3 +212,17 @@ def decorate(mlist, template, extradict=None):
text = Template(template).safe_substitute(d)
# Turn any \r\n line endings into just \n
return re.sub(r' *\r?\n', r'\n', text)
+
+
+
+class Decorate:
+ """Decorate a message with headers and footers."""
+
+ implements(IHandler)
+
+ name = 'decorate'
+ description = _('Decorate a message with headers and footers.')
+
+ def process(self, mlist, msg, msgdata):
+ "See `IHandler`."""
+ process(mlist, msg, msgdata)