Robert wrote:
That turns into periodic new RETR commands with offset. Think its more an "odd" trick. I'd even prefer a threaded approach (thread puts the blocks into a stack; a while ... yield generator loop in the main thread serves the .read() function of the pseudo file object, which is my wish). Yet such tricks are all kind of OS-level tricks with a lot of overhead.Don't know whether this would be helpful as a starting point, but a while (hmm, some years ...) ago I wrote an example of how FTP could be used as a file-like object. Look for ftpStream.py on
I wonder really, if the Python language itself can express an elegant flat solution to turn the block delivering callback function into a generator/.read(bytes) solution? I found no way.
http://www.holdenweb.com/Python/
Of course, in those days files could do a bit less than they can now, so there's no attempt to provide an iterator interface.
(Looking over some Ruby stuff, Ruby seems to be able to do so from the language. I am not really familiar to Ruby. I always felt Python to be as complete - but much more clean. I became somewhat jealous ... :-) )You will note that my code uses delegation to an FTP object rather than inheritance. Maybe you would find that approach more fruitful for your application.
As the solution in my case has to stand many different file systems compatibly ( file.read(bytes) function !) and also other FTPS & SFTP classes with different retrbinary functions have to be compatible, I cannot even make a simple FTP subclassed retrbinary without getting really weired. Thus the existing .retrbinary with callback is the "official interface in this game".
regards Steve -- Meet the Python developers and your c.l.py favorites March 23-25 Come to PyCon DC 2005 http://www.pycon.org/ Steve Holden http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list