From 5586b333dfd2b3d79f0b86ebf7252106e1714bf0 Mon Sep 17 00:00:00 2001 From: Nicolas Delaby <nicolas@nexedi.com> Date: Wed, 12 May 2010 16:27:34 +0000 Subject: [PATCH] * Try to read content_type from property it self first. * no need to call getTextFormat, this property hsa been removed git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35243 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/Document/File.py | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/product/ERP5/Document/File.py b/product/ERP5/Document/File.py index b398fbc3f5..1ca5afbb5c 100644 --- a/product/ERP5/Document/File.py +++ b/product/ERP5/Document/File.py @@ -198,26 +198,18 @@ class File(Document, CMFFile): """This method returns a tuple which contains mimetype and content.""" from Products.ERP5.Document.EmailDocument import MimeTypeException # return a tuple (mime_type, data) - mime_type = None content = None - - # WARNING - this could fail since getContentType - # is not (yet) part of Document API - if getattr(self, 'getContentType', None) is not None: - mime_type = self.getContentType() - elif getattr(self, 'getTextFormat', None) is not None: - mime_type = self.getTextFormat() - else: - raise ValueError, "Cannot find mimetype of the document." - - if mime_type is not None: - try: - mime_type, content = self.convert(mime_type) - except ConversionError: - mime_type = self.getBaseContentType() - content = self.getBaseData() - except (NotImplementedError, MimeTypeException): - pass + mime_type = self.getContentType() + + if mime_type is None: + raise ValueError('Cannot find mimetype of the document.') + try: + mime_type, content = self.convert(None) + except ConversionError: + mime_type = self.getBaseContentType() + content = self.getBaseData() + except (NotImplementedError, MimeTypeException): + pass if content is None: if getattr(self, 'getTextContent', None) is not None: -- 2.30.9