[Mailman-Users] Mass unsubscription

Dan Mick Dan.Mick at West.Sun.COM
Thu Jun 8 05:21:30 CEST 2000


In the "put up or shut up" category, I volunteer this patch to
add and process a "mass-unsubscribe" text box to the "Membership
Management" page for Mailman 1.1 (I haven't tried to make it 
apply to any 2.0 yet, although I'm sure the code will be similar).

It seems to work for me for a test list.  YMMV.  I'll submit
it over on mailman-developers too and see if anyone has any
criticism.

The file that changes is Cgi/admin.py:



*** admin.py.orig       Thu Jun  1 23:09:46 2000
--- admin.py    Wed Jun  7 20:18:52 2000
***************
*** 612,617 ****
--- 612,626 ----
      container.AddItem(Center(t))
      container.AddItem(Center(TextArea(name='subscribees',
                                        rows=10,cols=60,wrap=None)))
+     t = Table(width="90%")
+     t.AddRow([Center(Header(4, "Mass Remove Members"))])
+     t.AddCellInfo(t.GetCurrentRowIndex(),
+                   t.GetCurrentCellIndex(),
+                   bgcolor="#cccccc", colspan=8)
+     t.AddRow(["Enter one address to remove per line: <p>"])
+     container.AddItem(Center(t))
+     container.AddItem(Center(TextArea(name='unsubscribees',
+                                       rows=10,cols=60,wrap=None)))
      return container
  
  def FormatPasswordStuff():
***************
*** 877,882 ****
--- 886,920 ----
                      dirty = 1
          if unsubscribe_errors:
              document.AddItem(Header(5, "Error Unsubscribing:"))
+             items = map(lambda x: "%s -- %s" % (x[0], x[1]), unsubscribe_errors)
+             document.AddItem(apply(UnorderedList, tuple((items))))
+             document.AddItem("<p>")
+ 
+     #
+     # mass unsubscription processing for members category
+     #
+     if cgi_info.has_key('unsubscribees'):
+       name_text = cgi_info['unsubscribees'].value
+         name_text = string.replace(name_text, '\r', '')
+       names = map(string.strip, string.split(name_text, '\n'))
+         unsubscribe_errors = []
+         unsubscribe_success = []
+       for name in names:
+          try:
+             lst.DeleteMember(name)
+          except:
+             unsubscribe_errors.append(name, "No such user")
+          else:
+             unsubscribe_success.append(name)
+ 
+         if unsubscribe_success:
+             document.AddItem(Header(5, "Successfully Unsubscribed:"))
+             document.AddItem(apply(UnorderedList, tuple((unsubscribe_success))))
+             document.AddItem("<p>")
+             dirty = 1
+ 
+         if unsubscribe_errors:
+             document.AddItem(Header(5, "Error Unsubscribing:"))
              items = map(lambda x: "%s -- %s" % (x[0], x[1]), unsubscribe_errors)
              document.AddItem(apply(UnorderedList, tuple((items))))
              document.AddItem("<p>")





More information about the Mailman-Users mailing list