[Zope] contents of File as string: acquisition wrapper problem

Jonathan Hobbs toolkit at magma.ca
Fri Aug 27 18:05:00 EDT 2004


----- Original Message -----
From: "John Hunter" <jdhunter at nitace.bsd.uchicago.edu>
>
> What is the proper way to get the contents of a File as a string from
> the python API?
>
> I am doing
>
>         zip = zipfile.ZipFile(tmpfile, 'w')
>
>         for fileo in self._subfileFolder.objectValues('File'):
>             fname = fileo.getId()
>             zip.writestr(fname, fileo.data)
>         zip.close()
>
> But the call to writestr raises
>
>
> Error Type: TypeError
> Error Value: crc32() argument 1 must be string or read-only buffer, not
ImplicitAcquirerWrapper
>
> Traceback (innermost last):
>
>     * Module ZPublisher.Publish, line 101, in publish
>     * Module ZPublisher.mapply, line 88, in mapply
>     * Module ZPublisher.Publish, line 39, in call_object
>     * Module Products.irbworkflow.CRCFlow, line 1603, in all_zipped
>     * Module zipfile, line 460, in writestr
>
> TypeError: crc32() argument 1 must be string or read-only buffer, not
ImplicitAcquirerWrapper
>
>
> So it appears data is wrapped by the acquisition machinery.


I use a module found in  gzip.py which is (should be) part of your python
install, it does all the hard work.

Jonathan




More information about the Zope mailing list