Commit 7e275281 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Use _unpackData function instead of _unpackData method

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13956 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e4ec2882
...@@ -38,14 +38,15 @@ from AccessControl import ClassSecurityInfo ...@@ -38,14 +38,15 @@ from AccessControl import ClassSecurityInfo
from OFS.Image import Pdata from OFS.Image import Pdata
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from Products.CMFCore.utils import _setCacheHeaders from Products.CMFCore.utils import _setCacheHeaders
from Products.DCWorkflow.DCWorkflow import ValidationFailed
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5Type.Message import Message from Products.ERP5Type.Message import Message
from Products.ERP5Type.Cache import CachingMethod from Products.ERP5Type.Cache import CachingMethod
from Products.ERP5Type.XMLObject import XMLObject from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5.Document.File import File from Products.ERP5.Document.File import File
from Products.ERP5.Document.Document import ConversionCacheMixin, ConversionError from Products.ERP5.Document.Document import ConversionCacheMixin, ConversionError
from Products.CMFCore.utils import getToolByName from Products.ERP5.Document.File import _unpackData
from Products.DCWorkflow.DCWorkflow import ValidationFailed
from zLOG import LOG from zLOG import LOG
...@@ -54,7 +55,6 @@ dec=base64.decodestring ...@@ -54,7 +55,6 @@ dec=base64.decodestring
_MARKER = [] _MARKER = []
class OOoDocument(File, ConversionCacheMixin): class OOoDocument(File, ConversionCacheMixin):
""" """
A file document able to convert OOo compatible files to A file document able to convert OOo compatible files to
...@@ -229,7 +229,7 @@ class OOoDocument(File, ConversionCacheMixin): ...@@ -229,7 +229,7 @@ class OOoDocument(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(self._unpackData(self.getBaseData())) cs.write(_unpackData(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
...@@ -239,7 +239,7 @@ class OOoDocument(File, ConversionCacheMixin): ...@@ -239,7 +239,7 @@ class OOoDocument(File, ConversionCacheMixin):
return 'text/plain', s return 'text/plain', s
server_proxy = self._mkProxy() server_proxy = self._mkProxy()
kw = server_proxy.run_generate(self.getId(), kw = server_proxy.run_generate(self.getId(),
enc(self._unpackData(self.getBaseData())), enc(_unpackData(self.getBaseData())),
None, format) None, format)
return kw['mime'], Pdata(dec(kw['data'])) return kw['mime'], Pdata(dec(kw['data']))
...@@ -287,7 +287,7 @@ class OOoDocument(File, ConversionCacheMixin): ...@@ -287,7 +287,7 @@ class OOoDocument(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(self._unpackData(data)) cs.write(_unpackData(data))
z = zipfile.ZipFile(cs) z = zipfile.ZipFile(cs)
for f in z.infolist(): for f in z.infolist():
fn = f.filename fn = f.filename
...@@ -321,7 +321,7 @@ class OOoDocument(File, ConversionCacheMixin): ...@@ -321,7 +321,7 @@ class OOoDocument(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(self._unpackData(data)) archive_file.write(_unpackData(data))
zip_file = zipfile.ZipFile(archive_file) zip_file = zipfile.ZipFile(archive_file)
must_close = 1 must_close = 1
else: else:
...@@ -350,7 +350,7 @@ class OOoDocument(File, ConversionCacheMixin): ...@@ -350,7 +350,7 @@ class OOoDocument(File, ConversionCacheMixin):
# LOG('in _convertToBaseFormat', 0, self.getRelativeUrl()) # LOG('in _convertToBaseFormat', 0, self.getRelativeUrl())
server_proxy = self._mkProxy() server_proxy = self._mkProxy()
kw = server_proxy.run_convert(self.getSourceReference() or self.getId(), kw = server_proxy.run_convert(self.getSourceReference() or self.getId(),
enc(self._unpackData(self.getData()))) enc(_unpackData(self.getData())))
self._setBaseData(dec(kw['data'])) self._setBaseData(dec(kw['data']))
metadata = kw['meta'] metadata = kw['meta']
self._base_metadata = metadata self._base_metadata = metadata
...@@ -375,6 +375,6 @@ class OOoDocument(File, ConversionCacheMixin): ...@@ -375,6 +375,6 @@ class OOoDocument(File, ConversionCacheMixin):
""" """
server_proxy = self._mkProxy() server_proxy = self._mkProxy()
kw = server_proxy.run_setmetadata(self.getId(), kw = server_proxy.run_setmetadata(self.getId(),
enc(self._unpackData(self.getBaseData())), enc(_unpackData(self.getBaseData())),
kw) kw)
self._setBaseData(dec(kw['data'])) self._setBaseData(dec(kw['data']))
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