471,330 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,330 software developers and data experts.

PyPubSub module version 3 usage

Hello,

I just recently found out that wx.lib.pubsub has finally moved away from wx,
and now lives at:

http://pubsub.wiki.sourceforge.net

I'm trying to use pubsub3, which is the third version and now the default one,
but I'm having a hard time creating topics and messages for sending:
class Topic:
__init__(self, _name, _description, _parent=None, **kwargs)
| Specify the name, description, and parent of
| this Topic, and the list of kwargs allowed on listeners
| of this topic. The non-kwargs all start with a '_' to
| minimize the chance of conflict with a kwargs key.

from pubsub import pub
class Test(pub.Topic):
def __init__(self):
pub.Topic.__init__(self, 'Topic.Test', 'This is a test topic')

class Msg(pub.Message):
pass

pub.sendMessage(Test())

Traceback (most recent call last):
File "topics.py", line 80, in <module>
pub.sendMessage(Test())
File "build/bdist.linux-i686/egg/pubsub/pubsub3.py", line 421, in
sendMessage
File "build/bdist.linux-i686/egg/pubsub/pubsub3.py", line 195, in
sendMessage
File "/home/frank/test/topics.py", line 155, in getTopic
File "/home/frank/test/topics.py", line 162, in __getTopic

TypeError: iteration over non-sequence.

pub.sendMessage(Msg())

Traceback (most recent call last):
File "topics.py", line 80, in <module>
pub.sendMessage(Test())
File "build/bdist.linux-i686/egg/pubsub/pubsub3.py", line 421, in
sendMessage
File "build/bdist.linux-i686/egg/pubsub/pubsub3.py", line 195, in
sendMessage
File "/home/frank/test/topics.py", line 155, in getTopic
File "/home/frank/test/topics.py", line 162, in __getTopic

TypeError: iteration over non-sequence.
The variable in question for class Test() contains:

Topic 'T.o.p.i.c...T.e.s.t': This is a test topic. Listeners that have
'topic=pub.AUTO_PASS_TOPIC' as a kwarg will get the topic name as
value of topic (ie 'T.o.p.i.c...T.e.s.t'). Listeners must
otherwise be callable with no args.
No listeners are currently subscribed.
There are currently no subtopics.

which of course is non-iterable. Same for class Msg(), So obviously my Topic
and Message class constructors are wrong. The code on the wiki is for
pubsub2, and seems to be outdated compared to pubsub3 API. pubsub1 is the
same as wx.lib.pubsub btw.

Basically I'm looking for example code to get me kickstarted using pubsub3.

Best regards,
Frank
Nov 29 '07 #1
0 949

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by sj | last post: by
36 posts views Thread by Dag | last post: by
4 posts views Thread by Brad Tilley | last post: by
4 posts views Thread by Brad Parks | last post: by
reply views Thread by Crutcher | last post: by
1 post views Thread by alain MONTMORY | last post: by
1 post views Thread by bkamrani | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.