At 03:32 PM 6/14/2001 +0200, Fred Pacquier wrote:
>1) the file downloaded by the browser is not the original content. It
>has additional HTML tags added at the start and at the end (like the
>skeleton of an empty HTML template). I didn't see it right away as
>this doesn't bother JPEG or ZIP viewers, but downloaded EXE apps
>don't run anymore. Where do these come from ?...

If you're in a subclass of Page, you are probably getting it from that. 
Page as writeHTML() which cascades into various methods. You might take a 
moment to study Page.py, its writeHTML() methods and the ones that follow 
for your general WebKit education.

If your form submission button is tied to an action, then I think you could 
implement preAction() and postAction() to do pass and thereby not inherit 
any garbage.

Or you could subclass HTTPServlet.

Or possibly detect the action in awake(), forward to a subclass of 
HTTPServlet() (see Application.forwardURL()) and then refrain from 
generating any more content in the original servlet.


>2) Now I understand Ian's previous remark :
>"I'm not sure how you'd download several files at a time, but doing
>one file is fairly easy -- if you want, you could zip several files and
>download the zip file to the user."
>
>If I loop the above code over a list of files, I get only one download
>dialog in the browser (for the first file), and the downloaded file is
>the concatenation of all the source files... I've tried clearing the
>headers before sending each file, but that's probably not that
>function's function :)
>Is there any way around this ?

Not that I'm aware of. The best I can imagine, as I think Ian pointed out, 
was to send a tar file. Note that WinZip for Windows understands .tar files 
so it might not be that bad for your users.

Or maybe you can do some fancy JavaScript that would iterate over the files 
and open a new connection for each one. I think that's feasible, but it 
obviously requires some experimentation and work.

Finally, you might consider providing the user FTP links.


>Oh, and a final question : it looks like the Webkit server reads the
>entire file in memory before it starts the download. If so, this can
>become a problem with large files... Would "chunking" the file
>read/write (as in the "shutil" module) be enough to avoid that ?

WebKit (in CVS) already has streaming responses (thanks Jay) so most of the 
work is already done for you. The problem you are experiencing now is that 
the read() method on a file reads the whole file.

I think you can pass read() a max number of bytes, right? Something like:
         bufferSize = 10*1024
         ...
                 chunk = file.read(bufferSize)
                 res.write(chunk)

You need to loop through, exit on EOF or IOError, etc.


>TIA (& sorry for the pestering :)
>fp

You're not pestering at all. These are all great topics for the discussion 
list.



-Chuck


_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to