[Twisted-Python] Event dispatcher
glyph at divmod.com
glyph at divmod.com
Tue Apr 1 03:20:15 MDT 2008
On 06:36 am, mailing_lists at 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.
More information about the Twisted-Python
mailing list