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