Commit 9a6b739e authored by Jérome Perrin's avatar Jérome Perrin Committed by Arnaud Fontaine

dms: fix Image and PDF to text,html with cache

parent dfee1511
...@@ -38,7 +38,7 @@ from Acquisition import aq_base ...@@ -38,7 +38,7 @@ from Acquisition import aq_base
import Products.ERP5 import Products.ERP5
from Products.ERP5Type import Permissions, PropertySheet from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.Utils import fill_args_from_request from Products.ERP5Type.Utils import bytes2str, fill_args_from_request
from erp5.component.document.File import File from erp5.component.document.File import File
from erp5.component.document.Document import Document, ConversionError,\ from erp5.component.document.Document import Document, ConversionError,\
VALID_TEXT_FORMAT_LIST, VALID_TRANSPARENT_IMAGE_FORMAT_LIST,\ VALID_TEXT_FORMAT_LIST, VALID_TRANSPARENT_IMAGE_FORMAT_LIST,\
...@@ -280,7 +280,8 @@ class Image(TextConvertableMixin, File, OFSImage): ...@@ -280,7 +280,8 @@ class Image(TextConvertableMixin, File, OFSImage):
if format in VALID_TEXT_FORMAT_LIST: if format in VALID_TEXT_FORMAT_LIST:
try: try:
return self.getConversion(format=format) mime, data = self.getConversion(format=format)
return mime, bytes2str(data)
except KeyError: except KeyError:
mime_type, data = self._convertToText(format) mime_type, data = self._convertToText(format)
data = aq_base(data) data = aq_base(data)
......
...@@ -123,7 +123,8 @@ class PDFDocument(Image): ...@@ -123,7 +123,8 @@ class PDFDocument(Image):
""" """
if format == 'html': if format == 'html':
try: try:
return self.getConversion(format=format) mime, data = self.getConversion(format=format)
return mime, bytes2str(data)
except KeyError: except KeyError:
mime = 'text/html' mime = 'text/html'
data = self._convertToHTML() data = self._convertToHTML()
...@@ -131,7 +132,8 @@ class PDFDocument(Image): ...@@ -131,7 +132,8 @@ class PDFDocument(Image):
return (mime, data) return (mime, data)
elif format in ('txt', 'text'): elif format in ('txt', 'text'):
try: try:
return self.getConversion(format='txt') mime, data = self.getConversion(format='txt')
return mime, bytes2str(data)
except KeyError: except KeyError:
mime = 'text/plain' mime = 'text/plain'
data = self._convertToText() data = self._convertToText()
......
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