[Twisted-Python] Event dispatcher
Hello, I was searching for an event dispatching mechanism in twisted and I cam upon this : http://twistedmatrix.com/trac/browser/trunk/twisted/python/dispatch.py but apparently it's being depreciated. There is no mention of what replaces it though, does someone know? Is there no replacement? If so, that must mean that there is a better way of doing things, can someone please tell me how? Thank you, Gabriel
Gabriel Rossetti wrote:
Hello,
I was searching for an event dispatching mechanism in twisted and I cam upon this :
http://twistedmatrix.com/trac/browser/trunk/twisted/python/dispatch.py
but apparently it's being depreciated. There is no mention of what replaces it though, does someone know? Is there no replacement? If so, that must mean that there is a better way of doing things, can someone please tell me how?
Thank you, Gabriel
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Oh, I just saw that we should create our own event dispatcher mechanism. Why was it removed? Isn't it better that we all share one than recreate on every time? Gabriel
Andrew Bennetts wrote:
Gabriel Rossetti wrote: [...]
Oh, I just saw that we should create our own event dispatcher mechanism. Why was it removed? Isn't it better that we all share one than recreate on every time?
The short answer is that we're sharing one already, and it's called "Python" ;)
-Andrew.
fair enough :-) Gabriel
On Tue, 2008-04-01 at 09:12 +0200, Gabriel Rossetti wrote:
Gabriel Rossetti wrote:
Hello,
I was searching for an event dispatching mechanism in twisted and I cam upon this :
http://twistedmatrix.com/trac/browser/trunk/twisted/python/dispatch.py
but apparently it's being depreciated. There is no mention of what replaces it though, does someone know? Is there no replacement? If so, that must mean that there is a better way of doing things, can someone please tell me how?
There is also an event dispatcher in twisted.words.xish.utility that might be useful. -- Groetjes, ralphm
Ralph Meijer wrote:
On Tue, 2008-04-01 at 09:12 +0200, Gabriel Rossetti wrote:
Gabriel Rossetti wrote:
Hello,
I was searching for an event dispatching mechanism in twisted and I cam upon this :
http://twistedmatrix.com/trac/browser/trunk/twisted/python/dispatch.py
but apparently it's being depreciated. There is no mention of what replaces it though, does someone know? Is there no replacement? If so, that must mean that there is a better way of doing things, can someone please tell me how?
There is also an event dispatcher in twisted.words.xish.utility that might be useful.
I'm using twisted.words.xish.utility.EventDispatcher. Really easy, once I got the syntax right (to ignore all the xpath stuff): ed = EventDispatcher() ed.addObserver("//event/objectEvent", callbackFunc) ed.dispatch("event message", "//event/objectEvent") ed.removeObserver("//event/objectEvent", callbackFunc) Si -- Linux Counter: User# 424693
On 06:36 am, mailing_lists@evotex.ch wrote:
Hello,
I was searching for an event dispatching mechanism in twisted and I cam upon this :
http://twistedmatrix.com/trac/browser/trunk/twisted/python/dispatch.py
but apparently it's being depreciated. There is no mention of what replaces it though, does someone know? Is there no replacement? If so, that must mean that there is a better way of doing things, can someone please tell me how?
While various other ad-hoc event dispatchers exist throughout Twisted, the suggested replacement for t.p.dispatch is just writing your own function that calls functions. Personally, I've found that attempting to write a totally generic event dispatch system inevitably results in extremely complex code whose purpose is unclear. The one in xish which Ralph mentioned, for example, deals in part with XPath events; this is not a requirement that almost anything except the code for which it was written (twisted.words.protocols.jabber) will have. That said, there are other packages which provide very, very flexible dispatch mechanisms, if you like that sort of thing. One that I have heard a bunch of good things about is http://pylouie.org/ - again, I wouldn't recommend this personally, I'd look at your application and see what kind of events need dispatching and why, and write something geared towards that. After all, the core of an "event dispatcher" is simply a dictionary lookup and a for loop, not something that's particularly onerous to repeat every so often.
participants (5)
-
Andrew Bennetts -
Gabriel Rossetti -
glyph@divmod.com -
Ralph Meijer -
Simon Pickles