Commit 3b93c8e9 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

use str(pdata) instead of _unpackData(pdata) because Pdata.__str__ is defined.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28339 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent efd16a1e
...@@ -47,7 +47,6 @@ from Products.ERP5.Document.Document import PermanentURLMixIn ...@@ -47,7 +47,6 @@ from Products.ERP5.Document.Document import PermanentURLMixIn
from Products.ERP5.Document.Document import ConversionCacheMixin from Products.ERP5.Document.Document import ConversionCacheMixin
from Products.ERP5.Document.Document import ConversionError from Products.ERP5.Document.Document import ConversionError
from Products.ERP5.Document.Document import NotConvertedError from Products.ERP5.Document.Document import NotConvertedError
from Products.ERP5.Document.File import _unpackData
from zLOG import LOG, ERROR from zLOG import LOG, ERROR
enc=base64.encodestring enc=base64.encodestring
...@@ -317,7 +316,7 @@ class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin): ...@@ -317,7 +316,7 @@ class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin):
if format == 'text-content': if format == 'text-content':
# Extract text from the ODF file # Extract text from the ODF file
cs = cStringIO.StringIO() cs = cStringIO.StringIO()
cs.write(_unpackData(self.getBaseData())) cs.write(str(self.getBaseData()))
z = zipfile.ZipFile(cs) z = zipfile.ZipFile(cs)
s = z.read('content.xml') s = z.read('content.xml')
s = self.rx_strip.sub(" ", s) # strip xml s = self.rx_strip.sub(" ", s) # strip xml
...@@ -328,7 +327,7 @@ class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin): ...@@ -328,7 +327,7 @@ class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin):
server_proxy = self._mkProxy() server_proxy = self._mkProxy()
orig_format = self.getBaseContentType() orig_format = self.getBaseContentType()
generate_result = server_proxy.run_generate(self.getId(), generate_result = server_proxy.run_generate(self.getId(),
enc(_unpackData(self.getBaseData())), enc(str(self.getBaseData())),
None, None,
format, format,
orig_format) orig_format)
...@@ -362,7 +361,7 @@ class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin): ...@@ -362,7 +361,7 @@ class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin):
if format == 'base-data': if format == 'base-data':
if not self.hasBaseData(): if not self.hasBaseData():
raise NotConvertedError raise NotConvertedError
return self.getBaseContentType(), self.getBaseData() return self.getBaseContentType(), str(self.getBaseData())
if format == 'pdf': if format == 'pdf':
format_list = [x for x in self.getTargetFormatList() format_list = [x for x in self.getTargetFormatList()
if x.endswith('pdf')] if x.endswith('pdf')]
...@@ -416,7 +415,7 @@ class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin): ...@@ -416,7 +415,7 @@ class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin):
# Extra processing required since # Extra processing required since
# we receive a zip file # we receive a zip file
cs = cStringIO.StringIO() cs = cStringIO.StringIO()
cs.write(_unpackData(data)) cs.write(str(data))
z = zipfile.ZipFile(cs) # A disk file would be more RAM efficient z = zipfile.ZipFile(cs) # A disk file would be more RAM efficient
for f in z.infolist(): for f in z.infolist():
fn = f.filename fn = f.filename
...@@ -479,7 +478,7 @@ class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin): ...@@ -479,7 +478,7 @@ class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin):
format = format_list[0] format = format_list[0]
mime, data = self._convert(format) mime, data = self._convert(format)
archive_file = cStringIO.StringIO() archive_file = cStringIO.StringIO()
archive_file.write(_unpackData(data)) archive_file.write(str(data))
zip_file = zipfile.ZipFile(archive_file) zip_file = zipfile.ZipFile(archive_file)
must_close = 1 must_close = 1
else: else:
...@@ -503,7 +502,7 @@ class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin): ...@@ -503,7 +502,7 @@ class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin):
def _getExtensibleContent(self, request, name): def _getExtensibleContent(self, request, name):
if self.hasConversion(format='_embedded', file_name=name): if self.hasConversion(format='_embedded', file_name=name):
mime, data = self.getConversion(format='_embedded', file_name=name) mime, data = self.getConversion(format='_embedded', file_name=name)
return OFSFile(name, name, data, content_type=mime) return OFSFile(name, name, data, content_type=mime).__of__(self.aq_parent)
return PermanentURLMixIn._getExtensibleContent(self, request, name) return PermanentURLMixIn._getExtensibleContent(self, request, name)
# Base format implementation # Base format implementation
...@@ -525,7 +524,7 @@ class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin): ...@@ -525,7 +524,7 @@ class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin):
server_proxy = self._mkProxy() server_proxy = self._mkProxy()
response_code, response_dict, response_message = server_proxy.run_convert( response_code, response_dict, response_message = server_proxy.run_convert(
self.getSourceReference() or self.getId(), self.getSourceReference() or self.getId(),
enc(_unpackData(self.getData()))) enc(str(self.getData())))
if response_code == 200: if response_code == 200:
# sucessfully converted document # sucessfully converted document
self._setBaseData(dec(response_dict['data'])) self._setBaseData(dec(response_dict['data']))
...@@ -564,7 +563,7 @@ class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin): ...@@ -564,7 +563,7 @@ class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin):
server_proxy = self._mkProxy() server_proxy = self._mkProxy()
response_code, response_dict, response_message = \ response_code, response_dict, response_message = \
server_proxy.run_setmetadata(self.getId(), server_proxy.run_setmetadata(self.getId(),
enc(_unpackData(self.getBaseData())), enc(str(self.getBaseData())),
kw) kw)
if response_code == 200: if response_code == 200:
# successful meta data extraction # successful meta data extraction
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment