Hi everyone,

I just started using Webware and it is such a breath of fresh air in the Python Web 
development realm. Excellent job!

I'm trying to create a servlet which can return a Python string to the user's browser 
as a zip file download.  Information is sent from the user via a post request which is 
then processed by the servlet to produce a final string.  I could write that string to 
disk, zip the file, and redirect the user to the file.  But a Java guru friend of mine 
showed me a trick where he used java.util.zip (something like that) to do it all in 
memory without writing to disk.  This functionality is part of the built-in Java 
library he used.  This way things are fast and there's no need to write a special 
clean up program to try and guess when the user had downloaded the file.


This trick should be just as possible in Python but I haven't figured it out yet.  I 
know I can compress strings with zlib but I'm not sure how to create a response to 
make it look like a zip file to the user's browser.

Here's the meager first attempt I made without compressing the string just to see if 
the browser would behave as if it were seeing a zip file. I just added what I thought 
would be the appropriate mime type in the header:

from WebKit.Servlet import Servlet

class ZipSample(Servlet):
   def respond(self, trans):
       trans.response().write('Content-type: application/zip; 
name="test.zip"\nContent-Transfer-Encoding: base64\n\n\nHello, world!\n')

This servlet just returns the entire response string as a string.  Any ideas?

Thanks,
Joel



-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to