About Louie and lib.pubsub

I posted something about this to the Louie mailing list, but since there have been all of 5 messages there since last year, I didn’t really expect a reply, and indeed didn’t get one.

So at the risk of being off-topic I’m repeating myself here since this is the place I heard about Louie.

Here’s my quick comparison of how Louie measures up to wx.lib.pubsub:

  • on the plus side you can hook up arbitrary methods as callbacks, unlike wx.lib.pubsub where your callback always has to take a single
    Message parameter. With Louie, if you have a method sitting around that
    takes a ‘value’ parameter, you can hook up some notification to it directly rather
    than having to write an adapter that takes a Message, extracts the msg.data.value and then calls the function you really wanted to call.
    I’m sure there’s a cost you have to pay for this though. You can also just use positional arguments. So with louie you can do:

    louie.send('value_changed", sender, new_value)

and it can directly call a callback method like

def setDisplay(self, display):
self.text = str(display)

whereas with pubsub you’d have to make another method to call the setDisplay one, something like:

def onValueChanged(self, message):

    self.setDisplay(message.data['new_value'])

It’s just an extra two-liner, but still it’s kind of an annoyance for someone used to Qt’s way where signals can usually be hooked up to existing slots that are just setters. Maybe you can lambda it down to a one-liner, but it’s still a little extra work.

  • on the minus side Louie uses a single global dispatcher. In
    that respect wx.lib.pubsub is nicer, since you can create multiple
    dispatchers/Publishers with pubsub. This was a deal-breaker for
    me. If you have a app that creates two main document frames, it makes
    no sense for there to be a single dispatcher that processes all the signals in
    both frames. The dispatcher for events related to one document should
    really belong to that document, and not be global. Having said that,
    it doesn’t look like it would be terribly hard to fix Louie to make the
    dispatcher a class.

  • also on the minus side, like I said, I posted a message to the Louie mailing list
    and got no response. Seems like the project is pretty dead at this
    time.

–bb