[Mailman-Users] Script to list users with nomail property set to 1

Richard Barrett r.barrett at openinfo.co.uk
Tue Feb 17 12:04:24 CET 2004

On 17 Feb 2004, at 06:48, Geoff Powell wrote:

> Hello,
> I have been using mailman's withlist feature with a basic python script
> called nomail, to list all users in a database with the nomail property
> set to 1, it looked something like:
> import sys
> from Mailman import mm_cfg
> def nomail(list):
> 	for member in list.members.keys()
> 		if list.user_options[member] &&
> Mailman.mm_cfg.DisableDelivery:
> 			print member
> 	pass
> 	for member in list.digest_members.keys()
> 		if list.user_options[member] &&
> Mailman.mm_cfg.DisableDelivery:
> 			print member
> 	pass
> 	sys.exit(0)
> (There could be errors in this code block)
> Since updating the system, and mailman is now version 2.1.2-2, the
> script is not working correctly. It appears to be printing out ALL 
> users
> in the database, indicating they all have the nomail field set to 1.
> I have found that in /var/mailman/Mailman/Defaults.py, there is a line
> with a comment next to DisableDelivery stating it is obsolete (and
> DisableDelivery is set to 1, I assume this is why the users all have 
> the
> value as 1?). The line says I should use getDeliveryStatus(), is there
> any documentation on how I can update my script to utilise this method,
> or can anyone please give me a hint?

This works for me:

1. with $prefix/Mailman as your pwd, use the following command to find 
where the function is defined in the Python source:

find . -name "*.py" | xargs grep "def getDeliveryStatus"

2. from the output pick a module that implements the function; there 
are several implementations defined in different modules on different 

3. either read the code or use withlist to read the function's docstring

mailman at mailman:/mailman/run/Mailman> ../bin/withlist -i all-users-list
Loading list all-users-list (unlocked)
The variable `m' is the all-users-list MailList instance
 >>> from Mailman import MemberAdaptor
 >>> print MemberAdaptor.MemberAdaptor.getDeliveryStatus.__doc__
Return the delivery status of this member.

         Value is one of the module constants:

             ENABLED  - The deliveries to the user are not disabled
             UNKNOWN  - Deliveries are disabled for unknown reasons.  The
                        primary reason for this to happen is that we've 
                        their delivery status from a legacy version 
which didn't
                        keep track of disable reasons
             BYUSER   - The user explicitly disable deliveries
             BYADMIN  - The list administrator explicitly disabled 
             BYBOUNCE - The system disabled deliveries due to bouncing

         If member is not a member of the list, raise NotAMemberError.
mailman at mailman:/mailman/run/Mailman>

> Thanks in advance,
> Geoff
Richard Barrett                               http://www.openinfo.co.uk

More information about the Mailman-Users mailing list