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

Michael McAndrew michaelmcandrew at gmail.com
Tue Oct 16 13:33:54 CEST 2007


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 at value.net> wrote:
>
> 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