[mod_python] Dynamically Creating Large Downloads In The Dark

ijwilson at laspilitas.com ijwilson at laspilitas.com
Sun May 15 22:00:02 EDT 2005

Hello mod_python and friends,

  I was hoping someone could help me with some basic questions because I am 
kind of just running around stabbing in the dark.

  I am trying to create a file that a user can download.

So the file could be too large to just read() and write() all at once so I am 
pretty sure I have to use this method defined for the req object:
  sendfile(path[, offset, len])

So I figure to store my file for them to download I need to create a temporary 
file with a name to give to sendfile.  Now if I create a named temporary file 
using tempfile.NamedTemporaryFile(...) when I close the descriptor it is 
So it seems I must use tempfile.mkstemp() to create the file.. but then I am 
responsible for deleting it.  The files will be large and the disk might not 
have enough room for too many of them.

So in the end my questions are pretty much does what I am saying make sense 
and also how do I know when they are finished downloading the file when 
calling sendfile so that I can delete the file that I created with 
mkstemp() ?

Do I have to put something in cron that just hopes they are done downloading 
it?  I hope there is something better than that.

Thanks in advance.

More information about the Mod_python mailing list