[Mailman-Developers] Determining if a user or list has moderation

andy nicholson intothemist at gmail.com
Fri Apr 13 06:43:26 CEST 2007


Hi
You are calling the 'withlist' command wrong.

You havent specified what you put into the checkModerated.py script, but
thats kinda by the by, since

from "withlist -h":

    -r [module.]callable
        This can be used to run a script with the opened MailList object.
        This works by attempting to import `module' (which must be in the
        directory containing withlist, or already be accessible on your
        sys.path), and then calling `callable' from the module.  callable can
        be a class or function; it is called with the MailList object as the
        first argument.  If additional args are given on the command line,
        they are passed as subsequent positional args to the callable.

        Note that `module.' is optional; if it is omitted then a module with
        the name `callable' will be imported.

        The global variable `r' will be set to the results of this call.

if you use "-r" you need to call a function, not give it a script name
(hence the error  .. no ".py" attribute)

keep reading down that help screen, and ..
"
As another example, say you wanted to change the password for a particular
user on a particular list.  You could put the following function in a file
called `changepw.py':

from Mailman.Errors import NotAMemberError

def changepw(mlist, addr, newpasswd):
    try:
        mlist.setMemberPassword(addr, newpasswd)
        mlist.Save()
    except NotAMemberError:
        print 'No address matched:', addr

and run this from the command line:
 % bin/withlist -l -r changepw mylist somebody at somewhere.org foobar

"

hope that helps ;)

andy


On 13/04/07, Jeff Kunzelman (DHL) <Jeff.Kunzelman at dhl.com> wrote:
>
> I'm trying to write a script to determine what lists have users that
> have moderation turned on. I found the following example in the list
> archives using the withlist command
>
>
> from Mailman import mm_cfg
>
> def list_moderated(m):
>     for member in m.getMembers():
>         if m.getMemberOption(member, mm_cfg.Moderate):
>             print member
>
> However when I run the command:
>
> withlist -q -r checkModerated.py jww_test
>
> I get the following error:
> Traceback (most recent call last):
>   File "/home/mailman/bin/withlist", line 297, in ?
>     main()
>   File "/home/mailman/bin/withlist", line 269, in main
>     func = getattr(mod, callable)
> AttributeError: 'module' object has no attribute 'py'
>
> This seems pretty simple to me, but I don't have any python experience,
> this is my first brush with python. I do know perl, java and assorted
> other programming languages but you have to start somewhere when
> learning something new. Any help would be appreciated. Or you can
> forward this to your co-workers to make fun of the n00b.
>
>
> Jeff Kunzelman
> Principal Systems Engineer - Messaging Infrastructure
> DHL Worldwide Express - AMIS
> 8701 East Hartford Drive
> Scottsdale, AZ 85255
> USA
>
>
> _______________________________________________
> Mailman-Developers mailing list
> Mailman-Developers at python.org
> http://mail.python.org/mailman/listinfo/mailman-developers
> Mailman FAQ: http://www.python.org/cgi-bin/faqw-mm.py
> Searchable Archives: http://www.mail-archive.com/mailman-developers%40python.org/
> Unsubscribe: http://mail.python.org/mailman/options/mailman-developers/intothemist%40gmail.com
>
> Security Policy: http://www.python.org/cgi-bin/faqw-mm.py?req=show&file=faq01.027.htp
>


-- 
andy nicholson
+61 406 306 715


More information about the Mailman-Developers mailing list