[Twisted-Python] Basic twisted question

Torsten Irländer feldmatrix at gmx.de
Sat Jul 29 15:54:38 EDT 2006


On Sat, Jul 29, 2006 at 07:04:39PM +0200, Johann Borck wrote:
> Torsten Irländer wrote:
> 
> >Continuing this way I
> >would end up with many small protocols doing one single task, and
> >I'm not sure If this is a good approach. 
> >  
> >
> It sounds like you'd need to switch between those protocols while beeing
> connected if you want to be able to do several operations, this is not
> the way to use twisted protocol classes - of course it's ok to work with
> inheritance,  but for one protocol, like IMAP, you'll want one protocol
> class that does all operations (inherited or else). 

I agree with you. One single protocol class which handles all
operations might be the better way. I think my problem is a very
basic one and the examples I saw so far all did the following:

Build the factory client class wich instanciates the protocol. Within
this protcol class all steps to do a single task are more or less
automatic. That means that it is triggered by an eventhandler function and then in a
series of deferreds and callbacks the task is solved. I.e selecting
a Mailbox.
This way it is clear to me how to implement a protocol which does
one single task, but I'm missing a way how to implement more than
one action. I think my problem is that don't know who to start
an action in the protocol class which is not triggered by an
eventhandler like the "serverGreeting" method in the IMAP examples. 

> Mind that the protocol usually will, once instatiated
> from the Factory, stay till the end of that connection, serving
> subsequent requests, 

Yes that is what I want :) But at the moment I connect and
disconned to the server for each operation which is indeed a bad
way! But as described above it seems that I have some basic
problems in understandinding how to do this :(

best regards
Torsten





More information about the Twisted-Python mailing list