[mod_python] capturing uploaded file with progress info...

Eric St-Jean esj at wwd.ca
Tue Jan 11 22:30:23 EST 2005

sorry if this is has been covered, but i tried looking through this 
mailing list and google and usenet, but couldn't find anything 
i have a form, to upload a file to the server through mod_python/apache, 
on a debian stable server (apache 1.3.26-0woody6, mod_python 
2.7.8-0.0woody2, i386). it works perfectly fine.
i figured out how, when the client clicks on Submit, to get a popup to 
open which fetches a different webpage, along with state info sent with 
my idea was to get this other page to reload every x seconds, and it 
would show succintly how the upload was going (%, speed basically), just 
to give some feedback for large files.


a- i have no idea - and i've really looked in a lot of places and tried 
many things! - how to get information on how much data has been 
transferred, and how much the client said there would be! actually: i 
know how much he said there would be, as i have a headerparserhandler 
which sees the Content-Length; but i don't know how to get the current 
amount of data transferred

b- in the end, i get a file object, but i can't just move it (is it a 
pipe? a socket?), so i need to make a copy; this all seems very 
wasteful, to have apache get the file, put it in a tmp place, then me in 
mod_python copy the entire file over, and later on apache deleting its 
temp file...

Through some debugging, i saw that my headerparserhandler does see the 
request as the file transfer begins, but my pythonhandler - the one 
which sees the form data, and hence the file object - only sees the 
request once the transfer is over. What's more, the client only gets the 
reply after all this is done - doing req.send_http_header and req.write 
in the headerparserhandler doesn't actually get apache to send the 
headers and the first bit of a webpage until the whole file got in.

I suspect that many of the above statements are either obvious to most 
of you, or painfully wrong... i desperately need some pointers. I would 
rather not have to go to apache 2.0 if i don't have to, but please do 
tell me if that's the only way i'll get what i want... it might be the 
kick i needed to upgrade.

can anyone give me a quick hand? a functional code example perhaps??? it 
would so immensely appreciated.

thank you very much!

Eric St-Jean        esj at wwd.ca

More information about the Mod_python mailing list