Loading ...
Sorry, an error occurred while loading the content.

buildZipArchive

Expand Messages
  • Thorsten Weber
    Dear developers. I am trying to generate a zip file on server and store it in archtype file field. I
    Message 1 of 7 , May 6, 2011
    View Source
    • 0 Attachment
      Dear developers.

      I am trying to generate a zip file on server and store it in archtype file field.

      <dtml-call "setObjProperty('zip_file',exportfile,lang)">

      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.

      btw ... doing the same with an image works
      <dtml-call "setObjProperty('zip_file',myImage,lang)">

      setObjProperty is called within onChangeObjEvent Methode

      can anybody help?


      kind regards,  
      Thorsten Weber
    • Thorsten
      might be a missing before setObjProperty()? Greetings, tf
      Message 2 of 7 , May 6, 2011
      View Source
      • 0 Attachment
        might be a missing
        <dtml-call "setObjStateModified(REQUEST)">
        before setObjProperty()?

        Greetings, tf

        --- In zms-developers@yahoogroups.com, 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.
      • Thorsten Weber
        Nop. Sorry ... but this does not the trick. :( and as I said: it works with images. Any other ideas?
        Message 3 of 7 , May 6, 2011
        View Source
        • 0 Attachment

          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 zms-developers@yahoogroups.com, 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.


        • Thorsten
          well, starting with the thin contextual information on your problem: Find out the difference between myImage and exportfile , the latter seems to be
          Message 4 of 7 , May 6, 2011
          View Source
          • 0 Attachment
            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 zms-developers@yahoogroups.com, 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 zms-developers@yahoogroups.com, 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.
            > >
            > >
            >
          • Thorsten Weber
            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
            Message 5 of 7 , May 6, 2011
            View Source
            • 0 Attachment

              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.

              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 zms-developers@yahoogroups.com, 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 zms-developers@yahoogroups.com, 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.
              > >
              > >
              >


            • Thorsten Weber
              Now I write zipfile by hand to temp dir in py script: context.localfs_write(tempfolder + / + filename.rsplit( . )[0] + .zip , exportfile, mode= b ) and
              Message 6 of 7 , May 9, 2011
              View Source
              • 0 Attachment

                Now I write zipfile "by hand" to temp dir in py script:

                context.localfs_write(tempfolder + '/' + filename.rsplit('.')[0] + '.zip', exportfile, mode='b')

                and read it back to zms:

                            <dtml-let zipFile="localfs_read(tempfolder + '/' + filename.rsplit('.')[0] + '.zip', mode='b', REQUEST=None)">
                                <dtml-call "setObjProperty('image_file',zipFile,lang)">
                            </dtml-let>

                but this gives me:

                Exception TypeTypeError
                Exception Valuecoercing to Unicode: need string or buffer, filestream_iterator found

                Traceback (innermost last):

                • Module ZPublisher.Publish, line 125, in publish
                • Module Zope2.App.startup, line 238, in commit
                • Module transaction._manager, line 96, in commit
                • Module transaction._transaction, line 395, in commit
                • Module transaction._transaction, line 495, in _commitResources
                • Module ZODB.Connection, line 502, in commit
                • Module ZODB.Connection, line 1046, in savepoint
                • Module ZODB.Connection, line 555, in _commit
                • Module ZODB.Connection, line 582, in _store_objects
                • Module ZODB.serialize, line 407, in serialize
                • Module ZODB.serialize, line 416, in _dump
                • Module copy_reg, line 70, in _reduce_ex
                TypeError: coercing to Unicode: need string or buffer, filestream_iterator found

                Any ideas for that?


                regards, Thorsten





                Am 06.05.2011 um 15:26 schrieb Thorsten Weber:

                 


                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.

                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 zms-developers@yahoogroups.com, 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 zms-developers@yahoogroups.com, 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.
                > >
                > >
                >




              • Thorsten Weber
                Solution: After all I got with FileFromData(zipFile,filename=filename.rsplit( . )[0] + .zip ) the ZipFile stored in ZMS. It puzzles me a bit why this is
                Message 7 of 7 , May 11, 2011
                View Source
                • 0 Attachment
                  Solution:
                  After all I got with FileFromData(zipFile,filename=filename.rsplit('.')[0] + '.zip') the ZipFile stored in ZMS.

                  It puzzles me a bit why this is necessary ...
                  maybe this is a python version issue?

                  regards, Thorsten


                  Am 09.05.2011 um 10:43 schrieb Thorsten Weber:

                   


                  Now I write zipfile "by hand" to temp dir in py script:

                  context.localfs_write(tempfolder + '/' + filename.rsplit('.')[0] + '.zip', exportfile, mode='b')

                  and read it back to zms:

                              <dtml-let zipFile="localfs_read(tempfolder + '/' + filename.rsplit('.')[0] + '.zip', mode='b', REQUEST=None)">
                                  <dtml-call "setObjProperty('image_file',zipFile,lang)">
                              </dtml-let>

                  but this gives me:

                  Exception TypeTypeError
                  Exception Valuecoercing to Unicode: need string or buffer, filestream_iterator found

                  Traceback (innermost last):

                  • Module ZPublisher.Publish, line 125, in publish
                  • Module Zope2.App.startup, line 238, in commit
                  • Module transaction._manager, line 96, in commit
                  • Module transaction._transaction, line 395, in commit
                  • Module transaction._transaction, line 495, in _commitResources
                  • Module ZODB.Connection, line 502, in commit
                  • Module ZODB.Connection, line 1046, in savepoint
                  • Module ZODB.Connection, line 555, in _commit
                  • Module ZODB.Connection, line 582, in _store_objects
                  • Module ZODB.serialize, line 407, in serialize
                  • Module ZODB.serialize, line 416, in _dump
                  • Module copy_reg, line 70, in _reduce_ex
                  TypeError: coercing to Unicode: need string or buffer, filestream_iterator found

                  Any ideas for that?


                  regards, Thorsten





                  Am 06.05.2011 um 15:26 schrieb Thorsten Weber:

                   


                  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.

                  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 zms-developers@yahoogroups.com, 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 zms-developers@yahoogroups.com, 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.
                  > >
                  > >
                  >






                Your message has been successfully submitted and would be delivered to recipients shortly.