[Erp5-report] r26497 - in /erp5/trunk/products/ERP5/Document: PDFDocument.py TextDocument.py

nobody at svn.erp5.org nobody at svn.erp5.org
Sun Apr 19 14:18:48 CEST 2009


Author: jp
Date: Sun Apr 19 14:18:47 2009
New Revision: 26497

URL: http://svn.erp5.org?rev=26497&view=rev
Log:
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.

Modified:
    erp5/trunk/products/ERP5/Document/PDFDocument.py
    erp5/trunk/products/ERP5/Document/TextDocument.py

Modified: erp5/trunk/products/ERP5/Document/PDFDocument.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/PDFDocument.py?rev=26497&r1=26496&r2=26497&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/PDFDocument.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/PDFDocument.py [utf8] Sun Apr 19 14:18:47 2009
@@ -33,7 +33,7 @@
 from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
 from Products.ERP5Type.Cache import CachingMethod
 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 zLOG import LOG, WARNING
@@ -161,13 +161,11 @@
           portal_transforms = getToolByName(self, 'portal_transforms')
           result = portal_transforms.convertToData(mime_type, content,
                                                    context=self,
-                                                   filename=self.title_or_id(),
+                                                   filename=self.getTitleOrId(),
                                                    mimetype=src_mimetype)
           if result is None:
-              # portal_transforms fails to convert.
-              LOG('TextDocument.convert', WARNING,
-                  'portal_transforms failed to convert to %s: %r' % (mime_type, self))
-              result = ''
+            raise ConversionError('PDFDocument conversion error. '
+                                  'portal_transforms failed to convert to %s: %r' % (mime_type, self))
           text += result
       return text
 

Modified: erp5/trunk/products/ERP5/Document/TextDocument.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/TextDocument.py?rev=26497&r1=26496&r2=26497&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/TextDocument.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/TextDocument.py [utf8] Sun Apr 19 14:18:47 2009
@@ -33,7 +33,7 @@
 from Products.CMFCore.utils import getToolByName
 from Products.CMFCore.utils import _setCacheHeaders, _ViewEmulator
 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.CMFDefault.utils import isHTMLSafe
 import re
@@ -209,17 +209,15 @@
         src_mimetype = 'text/%s' % src_mimetype
       # check if document has set text_content and convert if necessary
       text_content = self.getTextContent()
-      if text_content is not None:
+      if text_content:
         portal_transforms = getToolByName(self, 'portal_transforms')
         result = portal_transforms.convertToData(mime_type, text_content,
                                                  object=self, context=self,
-                                                 filename=self.title_or_id(),
+                                                 filename=self.getTitleOrId(),
                                                  mimetype=src_mimetype)
         if result is None:
-            # portal_transforms fails to convert.
-            LOG('TextDocument.convert', WARNING,
-                'portal_transforms failed to convert to %s: %r' % (mime_type, self))
-            result = ''
+          raise ConversionError('TextDocument conversion error. '
+                                'portal_transforms failed to convert to %s: %r' % (mime_type, self))
 
         if substitution_method_parameter_dict is None:
           substitution_method_parameter_dict = {}




More information about the Erp5-report mailing list