[Mailman-Users] Changing list options under script control?
gerrit.holl at pobox.com
Wed Feb 16 20:31:07 CET 2000
Andy Holyer wrote on 950718197:
> OK, here's what I'd like to do. I can appreciate the steps necessary, but I
> don't know python, which means I don't know exactly what to do.
If you are a programmer, learning Python can be done within an hour!
http://www.python.org/doc/current/tut/tut.html. Without this little
knowledge, I recommend not to program Mailman...
> I need to set the options for a site from a program, rather than from the
> web page. This is because we run a number of sites, each of which should
> have a postmaster-only list associated with it. To add a new site, I need to
> specifically run newlist, edit /etc/aliases, run newaliases, then go to the
> new list's web page to change the options. Id' like all of this to run from
> the script which adds a new site.
> I realise that I need to modify ~mailman/lists/listname/config.db (I think?
> I may have the filename/path wrong - I looked this up yesterday). However I
> can't find the fragment of python code which does this. Any hints would be
> gratefully received.
The Save() method does that. It saves all attributes of the instance in
a file. So all list options are attributes of the class instance.
Either from the interactive or from the non-interactive Python
interpreter, you can access the list through a class.
First, you need to add the mailman directory to sys.path:
>>> sys.path.insert(0, '/local/mailman')
Next, you can import the modules. Note that 'Mailman' is a package.
>>> from Mailman import MailList, Utils
You can create the instance now. 'postal' is the name of the list.
The second argument, 'lock', can be either 0 or 1: 1 when you are
going to change things, like you, 0 if not.
>>> l = MailList.MailList('postal', lock=1)
You can set options now, like:
>>> l.moderated = 1
>>> l.owner = "postmaster at nl.linux.org"
In the source code, see the GetConfigInfo() method for information
about the configuration info.
For programming Mailman, you'll need to know about Mailmans internals;
have you already read the paper on this?
cat: /home/gerrit/.signature: No such file or directory
More information about the Mailman-Users