Hi, Am Fr, den 27.08.2004 schrieb John Hunter um 22:08:
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.
Any ideas?
put str() around the fileo.data or use the objects read() method IIRC. Regards Tino