subscribing subscribers to topics
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?
-- Christopher Adams
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@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
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@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@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@state.or.us
On Fri, Jun 11, 2004 at 10:00:48AM -0700, Christopher Adams wrote:
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.
Spelling error? addtopics.py instead of addtopic.py?
From the command line, I issued the command: ./withlist -l -r addtopic testlist joe.blow@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
By default bin/withlist -r will run a function from a module of the same name... so a function called addtopic in the addtopic.py module is the least typing. :-)
But, you can specify the module name and the callable function:
$ bin/withlist -l -r addtopics.addtopic testlist joe.blow@anywhere Licensing
-- Jim Tittsler http://www.OnJapan.net/ GPG: 0x01159DB6 Python Starship http://Starship.Python.net/ Ringo MUG Tokyo http://www.ringo.net/rss.html
That addtopics.py was a typo. The name of the file is addtopic.py, but when I run withlist, I get the error message that I quoted, that the addtopic module doesn't exist. Do I have to 'install' the module or something? I am a novice with Python, so am unfamiliar with modules, but I have been reading a bit. Any help is most appreciated.
Jim Tittsler wrote:
On Fri, Jun 11, 2004 at 10:00:48AM -0700, Christopher Adams wrote:
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.
Spelling error? addtopics.py instead of addtopic.py?
From the command line, I issued the command: ./withlist -l -r addtopic testlist joe.blow@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
By default bin/withlist -r will run a function from a module of the same name... so a function called addtopic in the addtopic.py module is the least typing. :-)
But, you can specify the module name and the callable function:
$ bin/withlist -l -r addtopics.addtopic testlist joe.blow@anywhere Licensing
-- Christopher Adams Library Systems Analyst Oregon State Library 503-378-4243 258 chris.a.adams@state.or.us
At 10:41 AM -0700 2004-06-14, Christopher Adams wrote:
That addtopics.py was a typo. The name of the file is addtopic.py, but when I run withlist, I get the error message that I quoted, that the addtopic module doesn't exist. Do I have to 'install' the module or something? I am a novice with Python, so am unfamiliar with modules, but I have been reading a bit. Any help is most appreciated.
I don't see this module listed on the page at
<http://www.list.org/site.html>, or in the Mailman FAQ entry at <http://www.python.org/cgi-bin/faqw-mm.py?req=show&file=faq04.009.htp>.
Looking at my own 2.1.4 installation, the only files I find
anywhere on the system which include the string "opic" anywhere in the file name are in /usr/local/mailman, named:
% find . -name \*opic\* -print
./Mailman/Gui/Topics.py
./Mailman/Gui/Topics.pyc
./Mailman/TopicMgr.py
./Mailman/TopicMgr.pyc
I'm not sure that this module exists, or that it is used in this way.
-- Brad Knowles, <brad.knowles@skynet.be>
"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin, Historical Review of Pennsylvania.
SAGE member since 1995. See <http://www.sage.org/> for more info.
I see what you are saying, but the instructions were to create a file called addtopic.py, include certain information in it, and then run it with the withlist command. While reading abou Python modules, it says that you can install them. I don't know much about Python and am just fishing for answers to my various questions.
Brad Knowles wrote:
At 10:41 AM -0700 2004-06-14, Christopher Adams wrote:
That addtopics.py was a typo. The name of the file is addtopic.py, but when I run withlist, I get the error message that I quoted, that the addtopic module doesn't exist. Do I have to 'install' the module or something? I am a novice with Python, so am unfamiliar with modules, but I have been reading a bit. Any help is most appreciated.
I don't see this module listed on the page at
<http://www.list.org/site.html>, or in the Mailman FAQ entry at <http://www.python.org/cgi-bin/faqw-mm.py?req=show&file=faq04.009.htp>.
Looking at my own 2.1.4 installation, the only files I find
anywhere on the system which include the string "opic" anywhere in the file name are in /usr/local/mailman, named:
% find . -name \*opic\* -print ./Mailman/Gui/Topics.py ./Mailman/Gui/Topics.pyc ./Mailman/TopicMgr.py ./Mailman/TopicMgr.pyc I'm not sure that this module exists, or that it is used in this way.
-- Christopher Adams Library Systems Analyst Oregon State Library 503-378-4243 258 chris.a.adams@state.or.us
At 1:02 PM -0700 2004-06-14, Christopher Adams wrote:
I see what you are saying, but the instructions were to create a file called addtopic.py, include certain information in it, and then run it with the withlist command. While reading abou Python modules, it says that you can install them. I don't know much about Python and am just fishing for answers to my various questions.
Sorry, my mistake. I misunderstood the question being asked, and
did not connect it with the messages previously sent by Jim Tittsler on this subject.
Unfortunately, you're talking about issues with programming in
Python, and I'm not a programmer, nor do I know anything about Python. I think you're going to have to work out these issues with Jim, or someone else on the list who has knowledge in these areas.
If/when you can find a solution to this problem, perhaps you
could send that information to Christopher Kolar (ckolar@admin.aurora.edu), so that he could make suitable updates to documentation at <http://staff.imsa.edu/~ckolar/mailman/mailman-administration-v2.html>.
-- Brad Knowles, <brad.knowles@skynet.be>
"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin, Historical Review of Pennsylvania.
SAGE member since 1995. See <http://www.sage.org/> for more info.
On Jun 15, 2004, at 02:41, Christopher Adams wrote:
That addtopics.py was a typo. The name of the file is addtopic.py, but when I run withlist, I get the error message that I quoted, that the addtopic module doesn't exist.
I typically keep the *.py files I use with withlist in either the top
level Mailman directory (sometimes referred to as $prefix or
/usr/local/mailman by default) or in its bin directory. If you put
addtopic.py in either of those directories, it should be found whether
you invoke withlist as 'bin/withlist' from the top level directory as I
suggested, or as './withlist' as you tried.
Do I have to 'install' the module or something?
No. It just needs to be in one of the places Python searches for a module. (This search path can be seen by examining the value of Python's sys.path variable. You could stick a 'print sys.path' just before the try to see the directories that will be searched for your new module.)
-- Jim Tittsler http://www.OnJapan.net/ GPG: 0x01159DB6 Python Starship http://Starship.Python.net/ Ringo MUG Tokyo http://www.ringo.net/rss.html
Yup, that was it, a path problem.
Thanks so much for your persistence in expaining this to me. It works now and will be of great help in further development of our list service.
I will post something on the list that summarizes the process. It probably should also be posted to be included in the FAQ. How do I do that?
Christopher Adams
Jim Tittsler wrote:
On Jun 15, 2004, at 02:41, Christopher Adams wrote:
That addtopics.py was a typo. The name of the file is addtopic.py, but when I run withlist, I get the error message that I quoted, that the addtopic module doesn't exist.
I typically keep the *.py files I use with withlist in either the top level Mailman directory (sometimes referred to as $prefix or
/usr/local/mailman by default) or in its bin directory. If you put addtopic.py in either of those directories, it should be found whether you invoke withlist as 'bin/withlist' from the top level directory as I suggested, or as './withlist' as you tried.Do I have to 'install' the module or something?
No. It just needs to be in one of the places Python searches for a module. (This search path can be seen by examining the value of Python's sys.path variable. You could stick a 'print sys.path' just before the try to see the directories that will be searched for your new module.)
-- Christopher Adams Library Systems Analyst Oregon State Library 503-378-4243 258 chris.a.adams@state.or.us
participants (4)
-
Brad Knowles
-
Christopher Adams
-
Jim Tittsler
-
Jim Tittsler