[Mailman-Users] moderation bit silently turns off on some lists

Mark Sapiro msapiro at value.net
Sun Sep 16 19:40:27 CEST 2007


Mark Sapiro wrote:
>
>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



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 at value.net>       The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan



More information about the Mailman-Users mailing list