Movatterモバイル変換
[0]ホーム
[Python-Dev] Generic notifier module
Moshe ZadkaMoshe Zadka <mzadka@geocities.com>
Thu, 20 Apr 2000 09:09:45 +0300 (IDT)
On Wed, 19 Apr 2000, Ka-Ping Yee wrote:> object.denotify(message[, callback]) - Turn off notification.You need to be a bit more careful here. What if callback isfoo().function? It's unique, so I could never denotify it. A betterway, and more popular (at least in the signal/slot terminology), is toreturn a cookie on connect, and have disconnect requests by a cookie.> object.send(message, **args) - Call all callbacks registered on> object for message, in reverse order of registration, passing> along message and **args as arguments to each callback.> If a callback returns notifier.BREAK, no further callbacks> are called.When I implemented that mechanism, I just used a special exception (StopCommandExecution). I prefer that, since it allows the programmermuch more flexibility (which I used) > (Alternatively, we could use signals/slots terminology:> connect/disconnect/emit. I'm not aware of anything the signals/slots> mechanism has that the above lacks.)Me neither. Some offer a variety of connect-methods: connect after, connect-before (this actually has some uses). Have a short look at theGtk+ signal mechanism -- it has all these. > 1. The 'message' passed to notify/denotify may be a class, and> the 'message' passed to send may be a class or instance of> a message class. In this case callbacks registered on that> class and all its bases are called.This seems a bit unneccessary, but YMMV. In all cases I've needed this,a simple string sufficed (i.e., method 2)Implementation nit: I usually useclass _BREAK:passBREAK=_BREAK()That way it is gurranteed that BREAK is unique. Again, I use this mostlywith exceptions.All in all, great idea Ping!--Moshe Zadka <mzadka@geocities.com>.http://www.oreilly.com/news/prescod_0300.htmlhttp://www.linux.org.il -- we put the penguin in .com
[8]ページ先頭