[Twisted-web] HTTPPageDownloader closes 'file-like object', file-like object goes bye-bye

s s listsin at integrateddevcorp.com
Fri Sep 19 21:06:13 EDT 2008


	This is my first post to this list.

	I've been using Twisted for a few (like three) days.  My wife had a  
baby two days ago, no, really.  I just got the other two kids to bed  
and thought I'd ask...sorry if this has been answered eleven-thousand  
times before but I did search the archives first.

	I'm writing a client app that needs to get the contents of a URL,  
usually just a web page.

	I'm trying to use client.py's downloadPage(url, file,  
contextFactory=None, *args, **kwargs):

	It claims to use a 'file' which, according to the docstring, can be a  
file or file-like object.
	It uses the HTTPDownloader class to perform the actual download.

	In the pageEnd(): method of HTTPDownloader, the 'file' is closed.

	Unfortunately, for 'file-like' objects, like StringIOs, this trashes  
the 'file'; not so useful since I need to work with the result.

	I realize I can subclass and override and such but it seems odd that  
a function that is documented to use a file-like object uses a class  
that will destroy something that's not a 'file.'

	I'm sure I'm missing something...or maybe nobody uses this 'cause  
there's something way better that I haven't discovered yet.



AKA: Steve Steiner


More information about the Twisted-web mailing list