List all Mailman members

One of the most common requests we used to receive for our Mailman installation was, “how can I get a list of all members?” Mailman automatically categorizes members alphabetically under their e-mail address’s first letter as soon as the number of users increases beyond a certain small count. So I added a “list all” option to the Membership Management options to handle this. This is very simple Mailman mod.

  1. In Mailman/Gui/Membership.py, I added one line to the function GetConfigSubCatgories.
  2. In Mailman/Cgi/admin.py, I modified two lines.

The function GetConfigSubCatgories in Mailman/Gui/Membership.py contains a list of all of the options of the Membership Management section.

[toggle code]

  • def GetConfigSubCategories(self, category):
    • if category == 'members':
      • return [('list', _('Membership List')),
          • ('add', _('Mass Subscription')),
          • ('remove', _('Mass Removal')),
          • ('listall', _('List All')),
          • ]
    • return None

This adds the text “List All” to the sub-options of the Membership Management area. The link will have the key “listall”. You can see this right away—just go to one of your lists and go to the Membership Management section.

The second step is to modify Mailman/Cgi/admin.py to recognize the “listall” option key. Since “listall” is just acting as if there are few enough members to show all one one page, this is easy.

There’s a line around line 494 in the “show_results” function in Mailman/Cgi/admin.py that reads:

  • if subcat not in ('list', 'add', 'remove'):

Change it to:

  • if subcat not in ('list', 'add', 'remove', 'listall'):

That keeps the code from thinking “listall” should be ignored.

Then, around line 901 in the “membership_options” function of Mailman/Cgi/admin.py, change:

  • if len(all) < chunksz:

to:

  • if len(all) < chunksz or subcat == 'listall':

That causes the display to act as if the membership size is small enough to not need “chunking” into alphabetically-segregated chunks. Your membership options will now contain a “List All” option that, when chosen, displays all members on the same page.