Commit 5586b333 authored by Nicolas Delaby's avatar Nicolas Delaby

* 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
parent 99d9517a
......@@ -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:
......
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