Re: Re: buildZipArchive
Thorsten Weber <[email protected]> Fri, 6 May 2011 15:26:56 +0200
| Newsgroups | gmane.comp.cms.zms.devel |
|---|---|
| Message-ID | <[email protected]> |
what I want to do is ...
an image uploaded into ZMS should be zipped and stored in a field of type file.
I tested it with a given image object (myImage) within zms ... which worked.
<dtml-let myImage ="getObjProperty('myImage',REQUEST)">
<dtml-call "setObjProperty('file', myImage,lang)">
</dtml-let>
now to my problem:
therefore I wanted to adapt the python script mentioned in the article below.
http://www.zms-publishing.com/dokumentation/magic/zip_archive_erstellen/index_ger.html
in ZMS home folder i created a python script - named packZip - with two parameters (tempfolder, filename)
tempfolder is created by localfs_tempfile() command
<dtml-let file="getObjProperty('myImage',REQUEST)" filename="file.getFilename()" tempfolder="localfs_tempfile()">
then the image is copied to the temporary folder
<dtml-call "localfs_write('%s/%s'%(tempfolder,filename),file.getData(),mode='b')">
this works so far.
i call the python script like this:
<dtml-let zipFile="packZip(tempfolder,filename)">
<dtml-call "setObjProperty('zipfile',zipFile,lang)">
</dtml-let>
this python script (packZip) builds a zipfile (in memory or in system filesystem) and asigns the zipfile to the variable exportfile
exportfile is the return value of a python script:
exportfile = context.buildZipArchive( '%s/*.*'%tempfolder )
return exportfile
even writing the exportfile into tempfolder within the python script works.
this all seems to work properly ... but i can not store the returned exportfile in zms.
when trying to store it in a text field there is a lot of junk ... but it seems to work somehow - so to say: there some data which is returned by the python script. ;)
I hope this makes the problem more clear.
regards, Thorsten
Am 06.05.2011 um 14:54 schrieb Thorsten:
> well, starting with the thin contextual information on your problem:
> Find out the difference between "myImage" and "exportfile", the latter seems to be unkoscher ...
>
> --- In [email protected], Thorsten Weber <tweber@...> wrote:
> > Nop.
> > Sorry ... but this does not the trick. :(
> > and as I said: it works with images.
> >
> > Any other ideas?
> >
> >
> > Am 06.05.2011 um 14:09 schrieb Thorsten:
> >
> > > might be a missing
> > > <dtml-call "setObjStateModified(REQUEST)">
> > > before setObjProperty()?
> > >
> > > Greetings, tf
> > >
> > > --- In [email protected], Thorsten Weber <tweber@> wrote:
> > > ...
> > > > I am trying to generate a zip file on server and store it in archtype file field.
> > > >
> > > > <dtml-call "setObjProperty('zip_file',exportfile,lang)">
> > > >
> > > > I followed this article (http://www.zms-publishing.com/dokumentation/magic/zip_archive_erstellen/index_ger.html)
> > > > but unfortunately it does not work for me:
> > > >
> > > > I can see on server the temp dir and in it the file to be zipped and the py-script returns exportfile but i dont get it stored in zms file field.
> > >
> > >
> >
>
>