[Mailman-Users] Mirror mailing list with web forum

Mark Sapiro mark at msapiro.net
Thu May 8 01:50:59 CEST 2014


On 05/07/2014 03:41 PM, Jon 1234 wrote:

> 
> I’d be very grateful for comments on the Mailman withlist scripts I’ve used:
> (a) will they still work when I upgrade to 2.1.18-1? and (b) is there a better
> way of doing it? Thanks in advance, and feel free to ask for further information!
> 
>  
> 
> #! /path/to/bin/python
> 
> from Mailman.Errors import
> NotAMemberError
> 
> def get_name(mlist, member):
> 
>    
> try:
> 
> 
>                 print
> '%s' % (mlist.getMemberName(member))
> 
>    
> except NotAMemberError:
> 
>        
> print 'No address matched:', member
> 
>  
> 
> #! /path/to/bin/python
> 
> from Mailman.Errors import
> NotAMemberError
> 
> def get_password(mlist, member):
> 
>    
> try:
> 
>                 print
> '%s' % (mlist.getMemberPassword(member))
> 
>    
> except NotAMemberError:
> 
>        
> print 'No address matched:', member


I'll assume that all the spacing and indentation anomalies are due to
mangling by your email client and try to ignore them, so your question
boils down to

Do the list methods getMemberName(member) and getMemberPassword(member)
work the same in 2.1.18-1 and throw the same NotAMemberError exception
if member is not a member?

The answer is an unequivocal Yes.

Note that the shebang line "#! /path/to/bin/python" is unnecessary since
these can't and don't run standalone.

On the other hand, it is a bit of overkill to do these as withlist
scripts because of the withlist setup and takedown. You could, e.g., do
something like

#! /path/to/bin/python
import sys
import paths
from Mailman import MailList
from Mailman.Errors import MMUnknownListError, NotAMemberError
try:
    mlist = MailList.MailList(sys.argv[1])
except MMUnknownListError:
    print 'No such list: %s' % sys.argv[1]
    sys.exit(1)
try:
    print mlist.getMemberName(sys.argv[2])
except NotAMemberError:
    print 'No address matched: %s' % member

as a standalone script to be run as

/path/to/mailman/bin/get_name listname memberaddress

and similarly for the password. Note this would need to be run from
Mailman's bin/ directory for import paths to work and get all the other
paths.

-- 
Mark Sapiro <mark at msapiro.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