[Zope] Re: Zipfile and dtml output for dynamic openoffice docs creation - SOLVED!

Luis Mariano Luporini lluporini@yahoo.com.ar
Mon, 24 Mar 2003 20:21:21 -0300


Stupid me!

writestr method of ZipFile class was the solution.

Sorry.

Luis.

Luis Mariano Luporini wrote:

> Hi list!
>
> I'm learning Zope and Python. I'm trying to generate an openoffice 
> writer doc dynamically.
>
> I'm using a dtml method that, by now, has static content and outputs a 
> xml oo writer friendly string (oo format compliant).
>
> I'd like to go through this procedure:
>
> 1) take the output of the dtml method and feed it into a python script,
> 2) in the script zip it (forcing something like content.xml to the 
> name of the zipped string taken from 1),
> 3) and then generate the correct hearders to allow a user with a 
> browser to download the zip file (indeed a sxw document).
>
> I've read through python docs and learnt a little about zipfile 
> module, but the write function of a ZipeFile object expects a filename 
> param that must refer to an existing filesystem file.
>
> Is it posible to get the output of 1 and generate a zipfile 
> (preferably in memory, StringIO i think), compressing just the that 
> output without the need to save it in the filesystem temporally?
>
>
> Thank in advance.
>
> Luis.
>
> PD: It's a great community out there. I really feel comfortable in 
> this list.
>