Commit 413bb6cd 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@28357 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 96caebfc
......@@ -46,15 +46,9 @@ mimetypes.init()
def _unpackData(data):
"""
Unpack Pdata into string
OBSOLETED. use str(data) instead, because Pdata.__str__ is defined.
"""
if isinstance(data, str):
return data
else:
data_list = []
while data is not None:
data_list.append(data.data)
data = data.next
return ''.join(data_list)
return str(data)
class File(Document, CMFFile, ConversionCacheMixin):
"""
......
......@@ -34,7 +34,6 @@ from Products.ERP5Type import Permissions, PropertySheet, Constraint, interfaces
from Products.ERP5Type.Cache import CachingMethod
from Products.ERP5.Document.Image import Image
from Products.ERP5.Document.Document import ConversionCacheMixin, ConversionError
from Products.ERP5.Document.File import _unpackData
from zLOG import LOG, WARNING
......@@ -82,7 +81,7 @@ class PDFDocument(Image, ConversionCacheMixin):
"""
if format is None:
RESPONSE.setHeader('Content-Type', 'application/pdf')
return _unpackData(self.data)
return str(self.data)
if format in ('html', 'txt', 'text'):
mime, data = self.convert(format)
RESPONSE.setHeader('Content-Length', len(data))
......@@ -129,7 +128,7 @@ class PDFDocument(Image, ConversionCacheMixin):
if not self.data:
return ''
tmp = tempfile.NamedTemporaryFile()
tmp.write(_unpackData(self.data))
tmp.write(str(self.data))
tmp.seek(0)
cmd = 'pdftotext -layout -enc UTF-8 -nopgbrk %s -' % tmp.name
r = os.popen(cmd)
......@@ -194,7 +193,7 @@ class PDFDocument(Image, ConversionCacheMixin):
if not self.data:
return ''
tmp = tempfile.NamedTemporaryFile()
tmp.write(_unpackData(self.data))
tmp.write(str(self.data))
tmp.seek(0)
cmd = 'pdftohtml -enc UTF-8 -stdout -noframes -i %s' % tmp.name
r = os.popen(cmd)
......@@ -219,7 +218,7 @@ class PDFDocument(Image, ConversionCacheMixin):
except AttributeError:
pass
tmp = tempfile.NamedTemporaryFile()
tmp.write(_unpackData(self.data))
tmp.write(str(self.data))
tmp.seek(0)
cmd = 'pdfinfo -meta -box %s' % tmp.name
r = os.popen(cmd)
......
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