From 413bb6cd2f7e3e746b9490cfb0f3331716ac043f Mon Sep 17 00:00:00 2001
From: Kazuhiko Shiozaki <kazuhiko@nexedi.com>
Date: Wed, 12 Aug 2009 14:50:30 +0000
Subject: [PATCH] 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
---
 product/ERP5/Document/File.py        | 10 ++--------
 product/ERP5/Document/PDFDocument.py |  9 ++++-----
 2 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/product/ERP5/Document/File.py b/product/ERP5/Document/File.py
index 73088eba0d..3ff7458371 100644
--- a/product/ERP5/Document/File.py
+++ b/product/ERP5/Document/File.py
@@ -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):
   """
diff --git a/product/ERP5/Document/PDFDocument.py b/product/ERP5/Document/PDFDocument.py
index a4f17fe9b8..5d7dd15e56 100644
--- a/product/ERP5/Document/PDFDocument.py
+++ b/product/ERP5/Document/PDFDocument.py
@@ -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)
-- 
2.30.9