summaryrefslogtreecommitdiff
path: root/Mailman/pipeline/file_recipients.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/file_recipients.py
parentb36de8a6a5b84021c003b728274f7e9e95861c9d (diff)
downloadmailman-69d158b13ae9cfa37040c2e7a664ca266b42050b.tar.gz
mailman-69d158b13ae9cfa37040c2e7a664ca266b42050b.tar.zst
mailman-69d158b13ae9cfa37040c2e7a664ca266b42050b.zip
Diffstat (limited to 'Mailman/pipeline/file_recipients.py')
-rw-r--r--Mailman/pipeline/file_recipients.py54
1 files changed, 36 insertions, 18 deletions
diff --git a/Mailman/pipeline/file_recipients.py b/Mailman/pipeline/file_recipients.py
index 0bee969f6..dfae732f0 100644
--- a/Mailman/pipeline/file_recipients.py
+++ b/Mailman/pipeline/file_recipients.py
@@ -19,28 +19,46 @@
from __future__ import with_statement
+__metaclass__ = type
+__all__ = ['FileRecipients']
+
+
import os
import errno
+from zope.interface import implements
+
from Mailman import Errors
+from Mailman.i18n import _
+from Mailman.interfaces import IHandler
-def process(mlist, msg, msgdata):
- if 'recips' in msgdata:
- return
- filename = os.path.join(mlist.full_path, 'members.txt')
- try:
- with open(filename) as fp:
- addrs = set(line.strip() for line in fp)
- except IOError, e:
- if e.errno <> errno.ENOENT:
- raise
- msgdata['recips'] = set()
- return
- # If the sender is a member of the list, remove them from the file recips.
- sender = msg.get_sender()
- member = mlist.members.get_member(sender)
- if member is not None:
- addrs.discard(member.address.address)
- msgdata['recips'] = addrs
+class FileRecipients:
+ """Get the normal delivery recipients from an include file."""
+
+ implements(IHandler)
+
+ name = 'file-recipients'
+ description = _('Get the normal delivery recipients from an include file.')
+
+ def process(self, mlist, msg, msgdata):
+ """See `IHandler`."""
+ if 'recips' in msgdata:
+ return
+ filename = os.path.join(mlist.full_path, 'members.txt')
+ try:
+ with open(filename) as fp:
+ addrs = set(line.strip() for line in fp)
+ except IOError, e:
+ if e.errno <> errno.ENOENT:
+ raise
+ msgdata['recips'] = set()
+ return
+ # If the sender is a member of the list, remove them from the file
+ # recipients.
+ sender = msg.get_sender()
+ member = mlist.members.get_member(sender)
+ if member is not None:
+ addrs.discard(member.address.address)
+ msgdata['recips'] = addrs