[Mailman-Users] subscribing subscribers to topics

Christopher Adams chris.a.adams at state.or.us
Fri Jun 11 19:00:48 CEST 2004


Thanks for your reply. As an experiment, I tried doing just as you said. 
I created a file named addtopics.py in the /lists/Mailman directory. 
 From the command line, I issued the command:  ./withlist -l -r addtopic 
testlist joe.blow at anywhere.com Licensing

The result follow:

Importing addtopic...
Traceback (most recent call last):
  File "./withlist", line 275, in ?
    main()
  File "./withlist", line 247, in main
    mod = __import__(module)
ImportError: No module named addtopic


What have I missed?

Jim Tittsler wrote:

> 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...
>
>
>

-- 
Christopher Adams
Library Systems Analyst
Oregon State Library
503-378-4243 258
chris.a.adams at state.or.us







More information about the Mailman-Users mailing list