Graham Dumpleton
grahamd at dscpl.com.au
Sun May 15 22:13:03 EDT 2005
Presuming that request cleanup handlers are still only executed after the whole file is sent when using sendfile(), use the method req.register_cleanup() to register a callback which is run and which would delete the file. Graham ijwilson at laspilitas.com wrote .. > 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 > deleted. > 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. > -Ian > > > > _______________________________________________ > Mod_python mailing list > Mod_python at modpython.org > http://mailman.modpython.org/mailman/listinfo/mod_python
|