moderation bit silently turns off on some lists
![](https://secure.gravatar.com/avatar/a61855861e6e8c488c4c51808da47481.jpg?s=120&d=mm&r=g)
Hi there,
I operate a number of mailing lists. Some of these lists are announce only lists. The annouce only lists work by setting everyone's moderation bit to 1 apart from those that have posting permission. This is done automatically by a script that takes its data from a remote database via a text file that is created when requested. (and yes, I know that's a long winded way of doing things!)
But every now and again on some lists (its only happened so far on large lists) all the moderation bits are set to 0 allowing anyone to post. Any ideas why this would be?
Below are the script that sets posting permissions [A] and a sample of the text file that inputs into this script [B].
Any ideas why this would happen? As always, many thanks if you can help.
PS I don't blame you if you tell me to use a simpler solution. In fact, I agree and I am completley redoing the project getting rid of the manual synching and using default mailman admin interface. But in the mean time it is still a problem that I would be really grateful if someone could help me find a solution to.
[A] from Mailman.Errors import NotAMemberError from Mailman import mm_cfg from os.path import isfile
whoCanPostListsData = []
if isfile('vawupdate/scripts/vaw_wcp.txt'): whoCanPostListsVAWFile = open('vawupdate/scripts/vaw_wcp.txt', 'r') for line in whoCanPostListsVAWFile: whoCanPostListsData.append(line.strip().split("/"))
def wcpupdate(mlist): global whoCanPostListsData if not mlist.Locked(): mlist.Lock() for whoCanPostLine in whoCanPostListsData: if mlist.internal_name()==whoCanPostLine[0]: if whoCanPostLine[2]=='0': mlist.setMemberOption(whoCanPostLine[1].strip(), mm_cfg.Moderate, mm_cfg.No) else: mlist.setMemberOption(whoCanPostLine[1].strip(), mm_cfg.Moderate, mm_cfg.Yes) print whoCanPostLine[1], ' set' mlist.Save() mlist.Unlock() [/A]
[B] bme/person1@example.org/1 bme/person2@example.org/1 bme/person3@example.org/1 bme/person4@example.net/1 bme/person5@example.net/1 bme/michaelmcandrew@gmail.com/0 [/B]
![](https://secure.gravatar.com/avatar/746f7519ba02fb0d815e59f305c53fa2.jpg?s=120&d=mm&r=g)
Michael McAndrew wrote:
Someone could log on to the admin interface and set everyone off using the button under Additional Member Tasks on the Membership List page. Some script could do it. I know of no way Mailman would do it automatically.
Presumably this is a withlist script. I would make the following change, but it may not help: @@ -1,3 +1,4 @@ +import sys from Mailman.Errors import NotAMemberError from Mailman import mm_cfg from os.path import isfile @@ -7,7 +8,11 @@ if isfile('vawupdate/scripts/vaw_wcp.txt'): whoCanPostListsVAWFile = open('vawupdate/scripts/vaw_wcp.txt', 'r') for line in whoCanPostListsVAWFile: - whoCanPostListsData.append(line.strip().split("/")) + entry = line.strip().split("/") + if len(entry) <> 3 or entry[2] not in ('0', '1'): + print >> sys.stderr, 'Skipping invalid entry: %s' % str(entry) + continue + whoCanPostListsData.append(entry) def wcpupdate(mlist): global whoCanPostListsData As far as recommendations for a different way, I would set Privacy options...->Sender filters->default_member_moderation to Yes if it isn't already. Then I would set everyone to Moderated using the button under Additional Member Tasks on the Membership List page. At this point all members are moderated and all new members will be moderated by default. Then I would have the authorized posters post using an Approved: header with the list's moderator password, but if you wish to have them be unmoderated, just unmoderate them manually via the admin interface. Unless the authorized posters change frequently, this should not be too burdensome. -- Mark Sapiro <msapiro@value.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
![](https://secure.gravatar.com/avatar/746f7519ba02fb0d815e59f305c53fa2.jpg?s=120&d=mm&r=g)
Mark Sapiro wrote:
Looking more closely, I would do the following (I was initially thrown off by the import of NotAMemberError - I didn't notice you didn't use it) @@ -1,3 +1,4 @@ +import sys from Mailman.Errors import NotAMemberError from Mailman import mm_cfg from os.path import isfile @@ -7,7 +8,11 @@ if isfile('vawupdate/scripts/vaw_wcp.txt'): whoCanPostListsVAWFile = open('vawupdate/scripts/vaw_wcp.txt', 'r') for line in whoCanPostListsVAWFile: - whoCanPostListsData.append(line.strip().split("/")) + entry = line.strip().split("/") + if len(entry) <> 3 or entry[2] not in ('0', '1'): + print >> sys.stderr, 'Skipping invalid entry: %s' % str(entry) + continue + whoCanPostListsData.append(entry) def wcpupdate(mlist): global whoCanPostListsData @@ -15,10 +20,16 @@ mlist.Lock() for whoCanPostLine in whoCanPostListsData: if mlist.internal_name()==whoCanPostLine[0]: - if whoCanPostLine[2]=='0': - mlist.setMemberOption(whoCanPostLine[1].strip(), mm_cfg.Moderate, mm_cfg.No) - else: - mlist.setMemberOption(whoCanPostLine[1].strip(), mm_cfg.Moderate, mm_cfg.Yes) - print whoCanPostLine[1], ' set' + try: + if whoCanPostLine[2]=='0': + mlist.setMemberOption(whoCanPostLine[1].strip(), + mm_cfg.Moderate, mm_cfg.No) + else: + mlist.setMemberOption(whoCanPostLine[1].strip(), + mm_cfg.Moderate, mm_cfg.Yes) + print whoCanPostLine[1], ' set' + except NotAMemberError: + print >> sys.stderr, '%s: not in %s' % (whoCanPostLine[1], + whoCanPostLine[0]) mlist.Save() mlist.Unlock() -- Mark Sapiro <msapiro@value.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
![](https://secure.gravatar.com/avatar/a61855861e6e8c488c4c51808da47481.jpg?s=120&d=mm&r=g)
Thanks for this advice, Very helpful - thought I'd write back to update you on what I did ... I incorperated your ideas, especially as regards trying and excepting. I refined my original idea a bit more too ... I decided the safest way to do things was to initially set everyone as moderated, and then only go through those that are admins and set their mod bits to off. so here is the script. actually, one more small question - the line that prints the error: should it have >> after the print command? Is that a part of the python language I'm not familiar with, or is it something an email client stuck in ?!?! Thanks a lot, michael """ def wcpupdate(mlist): global wcp_adminsdata global wcp_listsdata # lock the list if not mlist.Locked(): mlist.Lock() # set all people to moderated for wcp_listsline in wcp_listsdata: if mlist.internal_name()==wcp_listsline: for member in mlist.getMembers(): mlist.setMemberOption(member, mm_cfg.Moderate, mm_cfg.Yes) # set administrators to unmoderated for wcp_adminsline in wcp_adminsdata: try: if mlist.internal_name()==wcp_adminsline[0]: mlist.setMemberOption(wcp_adminsline[1].strip(), mm_cfg.Moderate, mm_cfg.No) except NotAMemberError: print >> sys.stderr, '%s: not in %s' % (wcp_adminsline[1], wcp_adminsline[0]) mlist.Save() # unlock the list mlist.Unlock() """ On 9/16/07, Mark Sapiro <msapiro@value.net> wrote:
![](https://secure.gravatar.com/avatar/746f7519ba02fb0d815e59f305c53fa2.jpg?s=120&d=mm&r=g)
Michael McAndrew wrote:
Very helpful - thought I'd write back to update you on what I did ...
Thanks for the report.
The '>>' is part of the print command. it is used to print to an open file descriptor other than sys.stdout. I.e.,
print 'some text'
and
print >> sys.stdout, 'some text'
are equivalent, and you can print to any 'object' that has a write() method with
print >> object, 'some text'
In this case, the construct
print >> sys.stderr, 'message text'
is used to send the error message to stderr rather than stdout.
-- Mark Sapiro <msapiro@value.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
![](https://secure.gravatar.com/avatar/746f7519ba02fb0d815e59f305c53fa2.jpg?s=120&d=mm&r=g)
Michael McAndrew wrote:
Someone could log on to the admin interface and set everyone off using the button under Additional Member Tasks on the Membership List page. Some script could do it. I know of no way Mailman would do it automatically.
Presumably this is a withlist script. I would make the following change, but it may not help: @@ -1,3 +1,4 @@ +import sys from Mailman.Errors import NotAMemberError from Mailman import mm_cfg from os.path import isfile @@ -7,7 +8,11 @@ if isfile('vawupdate/scripts/vaw_wcp.txt'): whoCanPostListsVAWFile = open('vawupdate/scripts/vaw_wcp.txt', 'r') for line in whoCanPostListsVAWFile: - whoCanPostListsData.append(line.strip().split("/")) + entry = line.strip().split("/") + if len(entry) <> 3 or entry[2] not in ('0', '1'): + print >> sys.stderr, 'Skipping invalid entry: %s' % str(entry) + continue + whoCanPostListsData.append(entry) def wcpupdate(mlist): global whoCanPostListsData As far as recommendations for a different way, I would set Privacy options...->Sender filters->default_member_moderation to Yes if it isn't already. Then I would set everyone to Moderated using the button under Additional Member Tasks on the Membership List page. At this point all members are moderated and all new members will be moderated by default. Then I would have the authorized posters post using an Approved: header with the list's moderator password, but if you wish to have them be unmoderated, just unmoderate them manually via the admin interface. Unless the authorized posters change frequently, this should not be too burdensome. -- Mark Sapiro <msapiro@value.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
![](https://secure.gravatar.com/avatar/746f7519ba02fb0d815e59f305c53fa2.jpg?s=120&d=mm&r=g)
Mark Sapiro wrote:
Looking more closely, I would do the following (I was initially thrown off by the import of NotAMemberError - I didn't notice you didn't use it) @@ -1,3 +1,4 @@ +import sys from Mailman.Errors import NotAMemberError from Mailman import mm_cfg from os.path import isfile @@ -7,7 +8,11 @@ if isfile('vawupdate/scripts/vaw_wcp.txt'): whoCanPostListsVAWFile = open('vawupdate/scripts/vaw_wcp.txt', 'r') for line in whoCanPostListsVAWFile: - whoCanPostListsData.append(line.strip().split("/")) + entry = line.strip().split("/") + if len(entry) <> 3 or entry[2] not in ('0', '1'): + print >> sys.stderr, 'Skipping invalid entry: %s' % str(entry) + continue + whoCanPostListsData.append(entry) def wcpupdate(mlist): global whoCanPostListsData @@ -15,10 +20,16 @@ mlist.Lock() for whoCanPostLine in whoCanPostListsData: if mlist.internal_name()==whoCanPostLine[0]: - if whoCanPostLine[2]=='0': - mlist.setMemberOption(whoCanPostLine[1].strip(), mm_cfg.Moderate, mm_cfg.No) - else: - mlist.setMemberOption(whoCanPostLine[1].strip(), mm_cfg.Moderate, mm_cfg.Yes) - print whoCanPostLine[1], ' set' + try: + if whoCanPostLine[2]=='0': + mlist.setMemberOption(whoCanPostLine[1].strip(), + mm_cfg.Moderate, mm_cfg.No) + else: + mlist.setMemberOption(whoCanPostLine[1].strip(), + mm_cfg.Moderate, mm_cfg.Yes) + print whoCanPostLine[1], ' set' + except NotAMemberError: + print >> sys.stderr, '%s: not in %s' % (whoCanPostLine[1], + whoCanPostLine[0]) mlist.Save() mlist.Unlock() -- Mark Sapiro <msapiro@value.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
![](https://secure.gravatar.com/avatar/a61855861e6e8c488c4c51808da47481.jpg?s=120&d=mm&r=g)
Thanks for this advice, Very helpful - thought I'd write back to update you on what I did ... I incorperated your ideas, especially as regards trying and excepting. I refined my original idea a bit more too ... I decided the safest way to do things was to initially set everyone as moderated, and then only go through those that are admins and set their mod bits to off. so here is the script. actually, one more small question - the line that prints the error: should it have >> after the print command? Is that a part of the python language I'm not familiar with, or is it something an email client stuck in ?!?! Thanks a lot, michael """ def wcpupdate(mlist): global wcp_adminsdata global wcp_listsdata # lock the list if not mlist.Locked(): mlist.Lock() # set all people to moderated for wcp_listsline in wcp_listsdata: if mlist.internal_name()==wcp_listsline: for member in mlist.getMembers(): mlist.setMemberOption(member, mm_cfg.Moderate, mm_cfg.Yes) # set administrators to unmoderated for wcp_adminsline in wcp_adminsdata: try: if mlist.internal_name()==wcp_adminsline[0]: mlist.setMemberOption(wcp_adminsline[1].strip(), mm_cfg.Moderate, mm_cfg.No) except NotAMemberError: print >> sys.stderr, '%s: not in %s' % (wcp_adminsline[1], wcp_adminsline[0]) mlist.Save() # unlock the list mlist.Unlock() """ On 9/16/07, Mark Sapiro <msapiro@value.net> wrote:
![](https://secure.gravatar.com/avatar/746f7519ba02fb0d815e59f305c53fa2.jpg?s=120&d=mm&r=g)
Michael McAndrew wrote:
Very helpful - thought I'd write back to update you on what I did ...
Thanks for the report.
The '>>' is part of the print command. it is used to print to an open file descriptor other than sys.stdout. I.e.,
print 'some text'
and
print >> sys.stdout, 'some text'
are equivalent, and you can print to any 'object' that has a write() method with
print >> object, 'some text'
In this case, the construct
print >> sys.stderr, 'message text'
is used to send the error message to stderr rather than stdout.
-- Mark Sapiro <msapiro@value.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
participants (2)
-
Mark Sapiro
-
Michael McAndrew