Commit 2c29f7df authored by Nicolas Delaby's avatar Nicolas Delaby

The purpose of getContentType is not to guess any content_type

from string format


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35236 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0fd43e44
...@@ -46,10 +46,6 @@ from Products.ERP5.Document.Document import Document, ConversionError,\ ...@@ -46,10 +46,6 @@ from Products.ERP5.Document.Document import Document, ConversionError,\
VALID_TEXT_FORMAT_LIST VALID_TEXT_FORMAT_LIST
from OFS.Image import Image as OFSImage from OFS.Image import Image as OFSImage
from OFS.Image import getImageInfo from OFS.Image import getImageInfo
try:
from OFS.content_types import guess_content_type
except ImportError:
from zope.contenttype import guess_content_type
from zLOG import LOG, WARNING from zLOG import LOG, WARNING
# import mixin # import mixin
...@@ -63,6 +59,7 @@ DEFAULT_DISPLAY_ID_LIST = ('nano', 'micro', 'thumbnail', ...@@ -63,6 +59,7 @@ DEFAULT_DISPLAY_ID_LIST = ('nano', 'micro', 'thumbnail',
DEFAULT_QUALITY = 75 DEFAULT_QUALITY = 75
_MARKER = []
class Image(TextConvertableMixin, File, OFSImage): class Image(TextConvertableMixin, File, OFSImage):
""" """
An Image is a File which contains image data. It supports An Image is a File which contains image data. It supports
...@@ -176,14 +173,15 @@ class Image(TextConvertableMixin, File, OFSImage): ...@@ -176,14 +173,15 @@ class Image(TextConvertableMixin, File, OFSImage):
return self.height return self.height
security.declareProtected(Permissions.AccessContentsInformation, 'getContentType') security.declareProtected(Permissions.AccessContentsInformation, 'getContentType')
def getContentType(self, format=''): def getContentType(self, default=_MARKER):
"""Original photo content_type.""" """Original photo content_type."""
self._upradeImage() self._upradeImage()
if self.get_size() and not self._baseGetContentType(): self._update_image_info() if self.hasData() and not self.hasContentType():
if format == '': self._update_image_info()
if default is _MARKER:
return self._baseGetContentType() return self._baseGetContentType()
else: else:
return guess_content_type('myfile.' + format)[0] return self._baseGetContentType(default)
# #
# Photo display methods # Photo display methods
......
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