[Erp5-report] r38313 nicolas - /erp5/trunk/products/ERP5/Document/File.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Sep 13 17:02:37 CEST 2010
Author: nicolas
Date: Mon Sep 13 17:02:29 2010
New Revision: 38313
URL: http://svn.erp5.org?rev=38313&view=rev
Log:
Get a new chance to have a successful conversion of File content
by looking into portal_tranforms machinery.
If the content_type of file is known by portal_transforms as supported
input content_type, we can expect a successful conversion.
Modified:
erp5/trunk/products/ERP5/Document/File.py
Modified: erp5/trunk/products/ERP5/Document/File.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/File.py?rev=38313&r1=38312&r2=38313&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/File.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/File.py [utf8] Mon Sep 13 17:02:29 2010
@@ -268,6 +268,7 @@ class File(Document, CMFFile):
+ [item[0] for item in temp_ods.getTargetFormatItemList()]\
+ [item[0] for item in temp_odg.getTargetFormatItemList()]\
+ [item[0] for item in temp_odb.getTargetFormatItemList()]
+ portal = self.getPortalObject()
if content_type.startswith('text'):
# We can wrap it into TextDocument
from Products.ERP5Type.Document import newTempTextDocument
@@ -295,6 +296,20 @@ class File(Document, CMFFile):
text_content=self.getData(),
content_type=content_type)
return temp_document.convert(format=format, **kw)
+ elif content_type in portal.portal_transforms._mtmap:
+ # Look if portal_transforms can handle the content_type
+ # of this File
+ mime_type = getToolByName(portal, 'mimetypes_registry').\
+ lookupExtension('name.%s' % format)
+ result = portal.portal_transforms.convertToData(mime_type, self.getData(),
+ object=self, context=self,
+ mimetype=content_type)
+ if not result:
+ raise ConversionError('File conversion error. '
+ 'portal_transforms failed to convert '\
+ 'from %s to %s; %r' % (content_type, mime_type,
+ self))
+ return str(mime_type), result
else:
# We didn't find suitable wrapper to convert this File
if format in VALID_TEXT_FORMAT_LIST:
More information about the Erp5-report
mailing list