PyPubSub module version 3 usage

F

Frank Aune

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,150
Latest member
MakersCBDReviews
Top