[Twisted-Python] POP3 improvements

Christopher Armstrong radix at twistedmatrix.com
Tue Dec 31 01:24:40 EST 2002


On Tue, Dec 31, 2002 at 05:16:39PM +1100, Andrew Bennetts wrote:
> Actually, I just realised, I fibbed about FTPClient... it does something
> a little unusual, and I'm interested in opinions on this.
> 
> Say you call FTPClient.list().  You don't get a Deferred, you actually have
> to pass in a Protocol *instance*, and as the data for FTPClient.list is
> received, it gets passed straight to that Protocol, via dataReceived.  In
> fact, the FTPClient internally makes a Factory for that connection, which
> (essentially) uses that Protocol, but that's an implementation detail.  This
> is a bit weird, though, because using an FTPClient involves creating
> Protocols without associated Factories, and nowhere else in Twisted does
> that.
> 
> [The reason why I got confused about Deferreds in the interface, is that I
> use Deferreds internally in FTPClient to manage all this.]
> 
> So this is actually another interface, possibly specific to FTP, where you
> pass a Protocol instance -- this allows for progressive processing of data,
> rather than all-at-once, and this feels "more Twisted" to me :)
>   
> So, to parse the results of an FTP listing, you pass in a
> FTPFileListProtocol... this is useful, but there probably should be a
> higher-level interface to this that returns a Deferred, for when you don't
> need to do custom parsing and don't care about progressive processing (i.e.
> most of the time).

Euughhh.. that sounds really horrible at first glance. Are there any
cases you can think of that actually make use of passing in different
Protocol classes? Also, how much less flexible would it be to simply
set the protocols as attributes on the FTPClient if you want to
override?  (similar to Factory.protocol). The FTPClient would then just use
'self.whateverProtocol'. This agrees much more with what a lot of
Twisted already does, I think.

-- 
 Twisted | Christopher Armstrong: International Man of Twistery
  Radix  |          Release Manager,  Twisted Project
---------+     http://twistedmatrix.com/users/radix.twistd/




More information about the Twisted-Python mailing list