[Twisted-Python] Cascading services (passing events through connected services)

Matthieu Brucher matthieu.brucher at gmail.com
Wed May 7 01:46:39 EDT 2008

2008/5/7 <glyph at divmod.com>:

> On 09:38 pm, matthieu.brucher at gmail.com wrote:
>> I'm currently trying to implement the JXTA standard (http://www.jxta.org)
>> in
>> Python using twisted (because it seems to be the right choice). I've
>> implemented the basic parts that are not network related, that is, not
>> much
>> ;)
> Of course it's the right choice.  Twisted is *awesome* ;-).
>> network -> TCP transport layer service -> endpoint service -> some other
>> high level services -> endpoint service -> TCP transport layer
> You use the word "service" a lot here and I'm not sure I understand it.
> There are, unfortunately, a dozen or so things you could mean by it.

Yes, I know, it is not perfectly clear in my head as well, I have to play
with twisted and JXTA a little more to have a clear picture.

>  Is there a sample somewhere that does something like this ? Each time an
>> event is sent to a listener (the TCP transport layer, the endpoint, ...)
>> that acts upon it. I've tried to find some samples over the Internet, but
>> perhaps someone has a pointer to help me ?
> Assuming I do understand what all those "service" and "->"s mean in the
> above text, all you need to do is to
>  1) have some objects
>  2) keep references between them to other objects
>  3) call methods on the relevant objects when the relevant things happen
> Quite often, people somehow arrive at the incorrect conclusion that because
> twisted is event-driven, it has some magic "event" mechanism you have to use
> to get different pieces of code to talk to each other. Quite the opposite;
> the whole point of Twisted is to reduce event-driven programming to just
> regular Python method calls.

That's what I thought reading the tutorial.

> It may help, if you need to relay messages from one connected Protocol
> object to another, that Protocol objects have a reference to their factory,
> and you can easily keep a list of "all connections" on that factory.  This
> is actually two of our FAQs - have a look at this one and the next one:
>   http://tinyurl.com/6hpfa7

Excallent ! Thanks a lot for this, it will help me a lot !

French PhD student
Website : http://matthieu-brucher.developpez.com/
Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92
LinkedIn : http://www.linkedin.com/in/matthieubrucher
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20080507/c1137029/attachment.htm 

More information about the Twisted-Python mailing list