[Twisted-Python] Serving files, again

Clark C. Evans cce at clarkevans.com
Wed Feb 26 14:20:02 EST 2003


On Wed, Feb 26, 2003 at 12:48:31AM +0100, Mario Ruggier wrote:
| Would anyone be able to clarify what the render() method should be
| such that the url  http://host/docs/some/file.txt will return the file
| at system location of: /Path/To/Somewhere/some/file.txt ?

I don't know if this is your question; but I'd return the contents
of file.txt when the file size is less than a pre-defined size, say 32K.
Beyond that, the file should be DEFERRED into a thread which sends
the file a chunk at a time.   Further, it'd be cool if I could 
specify in the request object if the response should be compressed
via gzip.

This brings up another clarification of Resource, it'd be nice
if there was a sub-class of Resource called a "FilterResource"
which basically didn't serve content but which perhaps consumed
path segments or arguments or cookies and perhaps altered the
request object.   A FilterResource would have an additional
method called "initRequest" which could add stuff like my 
pathargs variable, and in the above request could add a flag
to the request object specifying if the file content should
be compressed.

Clark




More information about the Twisted-Python mailing list