5 Each user has a moderation flag. When set, and the list is set to moderate
6 postings, then only members with a cleared moderation flag will be able to
7 email the list without having those messages be held for approval. The
8 'moderation' rule determines whether the message should be moderated or not.
10 >>> mlist = create_list('_xtest@example.com')
11 >>> rule = config.rules['moderation']
15 In the simplest case, the sender is not a member of the mailing list, so the
16 moderation rule can't match.
18 >>> msg = message_from_string("""\
19 ... From: aperson@example.org
20 ... To: _xtest@example.com
21 ... Subject: A posted message
24 >>> rule.check(mlist, msg, {})
27 Let's add the message author as a non-moderated member.
29 >>> from mailman.interfaces.usermanager import IUserManager
30 >>> from zope.component import getUtility
31 >>> user = getUtility(IUserManager).create_user(
32 ... 'aperson@example.org', 'Anne Person')
34 >>> address = list(user.addresses)[0]
35 >>> from mailman.interfaces.member import MemberRole
36 >>> member = address.subscribe(mlist, MemberRole.member)
37 >>> member.is_moderated
39 >>> rule.check(mlist, msg, {})
42 Once the member's moderation flag is set though, the rule matches.
44 >>> member.is_moderated = True
45 >>> rule.check(mlist, msg, {})
52 There is another, related rule for matching non-members, which simply matches
53 if the sender is /not/ a member of the mailing list.
55 >>> rule = config.rules['non-member']
59 If the sender is a member of this mailing list, the rule does not match.
61 >>> rule.check(mlist, msg, {})
64 But if the sender is not a member of this mailing list, the rule matches.
66 >>> msg = message_from_string("""\
67 ... From: bperson@example.org
68 ... To: _xtest@example.com
69 ... Subject: A posted message
72 >>> rule.check(mlist, msg, {})