[Mailman-Users] Re: withlist changepw.py help

Barry A. Warsaw barry at zope.com
Sun Dec 8 06:58:53 CET 2002

>>>>> "AS" == Ajay Sharma <ssharma at odc.net> writes:

    AS> I'm not a python programmer, but I can get around.  Anyway, I
    AS> started to play with the "/bin/withlist" program to get a
    AS> command-line method to change passwords.  My changepw.py
    AS> program looks like:

    | import string

    | def changepw(mlist, addr, newpasswd):
    |         addr = string.lower(addr)
    |         if mlist.passwords.has_key(addr):
    |                 mlist.passwords[string.lower(addr)] = newpasswd
    |                 mlist.Save()
    |         else:
    |                 print 'No address matched:', addr

    AS> [mailman at server bin]$ ./withlist -l -r changepw list addr
    AS> newpass Loading list: list (locked) Importing changepw ...
    AS> Running changepw.changepw() ...  Unlocking (but not saving)
    AS> list: list Finalizing

    AS> So why doesn't it save the changes to the list after the
    AS> password is changed??

If this is Mailman 2.1, I'd write changepw.py like so (untested):

-------------------- snip snip --------------------
from Mailman import Errors

def changepw(mlist, addr, newpasswd):
        mlist.setMemberPassword(addr, newpasswd)
    except Errors.NotAMember:
        print 'Not a member address:', addr
    except Errors.BadPasswordError:
        print 'Not a valid password'
-------------------- snip snip --------------------


More information about the Mailman-Users mailing list