Catching -all- events

Hi everybody,

the method DirectObject.bind() allows to bind a function or a method to a specific event. However, is there a way to send -all- events and their additional information to a single method or function?

An easy way to do it was to hack the messenger.send() method in and add the following code:

    self.catchAllMethod(event, sentArgs)
except Exception:

Of course self.catchAllMethod must be declared in messenger.init() and must be set by the application to point to an appropriate function or method, i.e.:

def myFunction(event, arguments):
     print("Event: " + event)
     print("Args:" + str(arguments))

messenger.catchAllMethod = myFunction

Is there a built-in way to achieve the same result?

I don’t think so. But this is actually a neat tip. Maybe some thing like this should be done.

Duck typing for the win! Just create your own MyMessenger class that inherits from Messenger or imitates it behavior, overrides some stuff and is put in place of base.messenger.

Your method works as well, but is maybe slightly hackier.

either this method doesn’t exist or the reference is incomplete here.