From: Ian B. <ia...@co...> - 2005-10-03 00:41:11
|
Hi. I'm thinking about adding an event system to SQLObject, and was thinking about using PyDispatcher for that. But I often want to dispatch based on the class of the object (aka sender), not the instance, and usually based on isinstance/issubclass, not identity. Events would be fired for basic operations like subclassing and instantiation. Well... as I'm thinking about it, I could just not use instance senders, and always send based on the class. And then I could set up a listener for a subclassing event, and clone all the listeners for the superclass to also listen to the subclass. Anyway, curious if anyone else has done something similar. The other thing I'm wondering about is how listeners can communicate back. There doesn't seem to be any way to cancel the event or cancel the other listeners, for instance -- I suppose a simple way would be to raise an exception, and after all not all events can be cancelled anyway (represented by the presence of lack of a try:except: around the line that raises the event). Another thought for communication is that the event contain a mutable argument. For instance, on a create-instance event the keyword argument dictionary could be passed in, and listeners could modify it. But again, curious if anyone has patterns they are used to. Ian |