Commit 9c80571b authored by Jean-Paul Smets's avatar Jean-Paul Smets

title_or_is not en ERP5 method. Use getTitleOrId. Also, not raising an error...

title_or_is not en ERP5 method. Use getTitleOrId. Also, not raising an error in case of portal_transforms error is wrong since it pollutes the cache with empty strings.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26497 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 90acee04
...@@ -33,7 +33,7 @@ from Products.CMFCore.utils import getToolByName ...@@ -33,7 +33,7 @@ from Products.CMFCore.utils import getToolByName
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5Type.Cache import CachingMethod from Products.ERP5Type.Cache import CachingMethod
from Products.ERP5.Document.Image import Image from Products.ERP5.Document.Image import Image
from Products.ERP5.Document.Document import ConversionCacheMixin from Products.ERP5.Document.Document import ConversionCacheMixin, ConversionError
from Products.ERP5.Document.File import _unpackData from Products.ERP5.Document.File import _unpackData
from zLOG import LOG, WARNING from zLOG import LOG, WARNING
...@@ -161,13 +161,11 @@ class PDFDocument(Image, ConversionCacheMixin): ...@@ -161,13 +161,11 @@ class PDFDocument(Image, ConversionCacheMixin):
portal_transforms = getToolByName(self, 'portal_transforms') portal_transforms = getToolByName(self, 'portal_transforms')
result = portal_transforms.convertToData(mime_type, content, result = portal_transforms.convertToData(mime_type, content,
context=self, context=self,
filename=self.title_or_id(), filename=self.getTitleOrId(),
mimetype=src_mimetype) mimetype=src_mimetype)
if result is None: if result is None:
# portal_transforms fails to convert. raise ConversionError('PDFDocument conversion error. '
LOG('TextDocument.convert', WARNING,
'portal_transforms failed to convert to %s: %r' % (mime_type, self)) 'portal_transforms failed to convert to %s: %r' % (mime_type, self))
result = ''
text += result text += result
return text return text
......
...@@ -33,7 +33,7 @@ from Products.ERP5Type.Base import WorkflowMethod ...@@ -33,7 +33,7 @@ from Products.ERP5Type.Base import WorkflowMethod
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from Products.CMFCore.utils import _setCacheHeaders, _ViewEmulator from Products.CMFCore.utils import _setCacheHeaders, _ViewEmulator
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5.Document.Document import Document from Products.ERP5.Document.Document import Document, ConversionError
from Products.ERP5Type.WebDAVSupport import TextContent from Products.ERP5Type.WebDAVSupport import TextContent
from Products.CMFDefault.utils import isHTMLSafe from Products.CMFDefault.utils import isHTMLSafe
import re import re
...@@ -209,17 +209,15 @@ class TextDocument(Document, TextContent): ...@@ -209,17 +209,15 @@ class TextDocument(Document, TextContent):
src_mimetype = 'text/%s' % src_mimetype src_mimetype = 'text/%s' % src_mimetype
# check if document has set text_content and convert if necessary # check if document has set text_content and convert if necessary
text_content = self.getTextContent() text_content = self.getTextContent()
if text_content is not None: if text_content:
portal_transforms = getToolByName(self, 'portal_transforms') portal_transforms = getToolByName(self, 'portal_transforms')
result = portal_transforms.convertToData(mime_type, text_content, result = portal_transforms.convertToData(mime_type, text_content,
object=self, context=self, object=self, context=self,
filename=self.title_or_id(), filename=self.getTitleOrId(),
mimetype=src_mimetype) mimetype=src_mimetype)
if result is None: if result is None:
# portal_transforms fails to convert. raise ConversionError('TextDocument conversion error. '
LOG('TextDocument.convert', WARNING,
'portal_transforms failed to convert to %s: %r' % (mime_type, self)) 'portal_transforms failed to convert to %s: %r' % (mime_type, self))
result = ''
if substitution_method_parameter_dict is None: if substitution_method_parameter_dict is None:
substitution_method_parameter_dict = {} substitution_method_parameter_dict = {}
......
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