[Mailman-Users] subscribing subscribers to topics

Jim Tittsler jwt at onjapan.net
Fri Jun 11 06:34:37 CEST 2004


On Jun 11, 2004, at 07:33, Christopher Adams wrote:

> Is there a way, other than using the subscriber user page to subsribe 
> subscribers to specific topics?. I have a list of about 1000 
> subscribers that I would like to break out into 5 topics. I don't want 
> to rely on the subscribers to have to do this. So, any ideas on how to 
> do this in batch via one of the provided MM utilities or other 
> methods?

You can do this sort of thing with bin/withlist, taking advantage of 
the documentation that is embedded in Mailman/MemberAdaptor.py.

Create a file called addtopic.py:

from Mailman.Errors import NotAMemberError
from Mailman import mm_cfg
import sys

def addtopic(m, addr, topic):
     try:
         if topic not in [x[0] for x in m.topics]:
             print topic, "is not a valid topic for list"
             sys.exit(2)
         topic_list = m.getMemberTopics(addr)
         # add the topic for this member if not already subscribed
         if topic not in topic_list:
             m.setMemberTopics(addr, topic_list + [topic])
         # set subscriber to not receive non-topical posts
         m.setMemberOption(addr, mm_cfg.ReceiveNonmatchingTopics, 
mm_cfg.No)
         m.Save()
     except NotAMemberError:
         print 'No address matched:', addr

Then to have a user on "mylist" watch the "pickles" topic:

$ bin/withlist -l -r addtopic mylist luser at domain.com pickles

bin/withlist gives you the full power of Python to play with, so you 
could replace 'topic'  with a variable number of arguments (so you 
could subscribe the user to multiple topics at once), or replace their 
topics instead of appending to them, or loop through a file of users to 
set them all in one go (instead of doing the looping at the shell 
level), or whatever...



-- 
Jim Tittsler             http://www.OnJapan.net/      GPG: 0x01159DB6
Python Starship          http://Starship.Python.net/
Ringo MUG Tokyo          http://www.ringo.net/rss.html





More information about the Mailman-Users mailing list