Commit b6f3cb06 authored by Julien Muchembled's avatar Julien Muchembled

BT: prefer .jpg for image/jpeg, and .bin for application/octet-stream

parent 3ae828d6
...@@ -11011,9 +11011,9 @@ ...@@ -11011,9 +11011,9 @@
<key> <string>extensions</string> </key> <key> <string>extensions</string> </key>
<value> <value>
<tuple> <tuple>
<string>bin</string>
<string>obj</string> <string>obj</string>
<string>so</string> <string>so</string>
<string>bin</string>
<string>a</string> <string>a</string>
</tuple> </tuple>
</value> </value>
...@@ -17635,9 +17635,9 @@ ...@@ -17635,9 +17635,9 @@
<key> <string>extensions</string> </key> <key> <string>extensions</string> </key>
<value> <value>
<tuple> <tuple>
<string>jpg</string>
<string>pjpg</string> <string>pjpg</string>
<string>jpeg</string> <string>jpeg</string>
<string>jpg</string>
<string>jpe</string> <string>jpe</string>
</tuple> </tuple>
</value> </value>
...@@ -286,7 +286,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO ...@@ -286,7 +286,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
def test_twoFileImportExportForImageIdentifyingTypeByContentType(self): def test_twoFileImportExportForImageIdentifyingTypeByContentType(self):
""" """
Test Business Template Import And Export With Image In Image Module Test Business Template Import And Export With Image In Image Module
where extension (.pjpg) is found by content_type where extension (.jpg) is found by content_type
""" """
image_data = """MalformedBase64HereiVBORw0KGgoAAAANSUhEUgAAAAUA image_data = """MalformedBase64HereiVBORw0KGgoAAAANSUhEUgAAAAUA
AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
...@@ -297,7 +297,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO ...@@ -297,7 +297,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
data = image_data, data = image_data,
content_type = "image/jpeg", content_type = "image/jpeg",
portal_type = "Image", portal_type = "Image",
), '.pjpg') ), '.jpg')
def test_twoFileImportExportForImageNotIdentifyingType(self): def test_twoFileImportExportForImageNotIdentifyingType(self):
""" """
...@@ -356,14 +356,14 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO ...@@ -356,14 +356,14 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
def test_twoFileImportExportForFileIdentifyingTypeByContentTypeObj(self): def test_twoFileImportExportForFileIdentifyingTypeByContentTypeObj(self):
""" """
Test Business Template Import And Export With File Test Business Template Import And Export With File
where extension (.obj) is identified by the content_type where extension (.bin) is identified by the content_type
""" """
self._checkTwoFileImportExportForDocumentInDocumentModule(dict( self._checkTwoFileImportExportForDocumentInDocumentModule(dict(
title = "foo", title = "foo",
data = "a test file", data = "a test file",
content_type = "application/octet-stream", content_type = "application/octet-stream",
portal_type = "File", portal_type = "File",
), '.obj') ), '.bin')
def test_twoFileImportExportForFileIdentifyingTypeByContentTypeEpub(self): def test_twoFileImportExportForFileIdentifyingTypeByContentTypeEpub(self):
""" """
......
...@@ -1612,7 +1612,7 @@ class TestDocument(TestDocumentMixin): ...@@ -1612,7 +1612,7 @@ class TestDocument(TestDocumentMixin):
image_count = builder._image_count image_count = builder._image_count
failure_message = 'Expected image not found in ODF zipped archive' failure_message = 'Expected image not found in ODF zipped archive'
# fetch image from zipped archive content then compare with ERP5 Image # fetch image from zipped archive content then compare with ERP5 Image
self.assertEqual(builder.extract('Pictures/%s.pjpg' % image_count), self.assertEqual(builder.extract('Pictures/%s.jpg' % image_count),
image.getData(), failure_message) image.getData(), failure_message)
# Continue the test with image resizing support # Continue the test with image resizing support
......
...@@ -86,6 +86,7 @@ from Products.ERP5Type.patches import DTMLDocument ...@@ -86,6 +86,7 @@ from Products.ERP5Type.patches import DTMLDocument
from Products.ERP5Type.patches import CMFCoreUtils from Products.ERP5Type.patches import CMFCoreUtils
from Products.ERP5Type.patches import ZopePageTemplate from Products.ERP5Type.patches import ZopePageTemplate
from Products.ERP5Type.patches import ZSQLMethod from Products.ERP5Type.patches import ZSQLMethod
from Products.ERP5Type.patches import MimetypesRegistry
# These symbols are required for backward compatibility # These symbols are required for backward compatibility
from Products.ERP5Type.patches.PropertyManager import ERP5PropertyManager from Products.ERP5Type.patches.PropertyManager import ERP5PropertyManager
......
from Products.MimetypesRegistry import MimeTypesRegistry, mime_types
preferred_extension_dict = {
"bin": "application/octet-stream",
"jpg": "image/jpeg",
}
def initialize(registry):
mime_types.initialize(registry)
for ext, mime in preferred_extension_dict.iteritems():
mime, = registry.lookup(mime)
assert type(mime.extensions) is tuple
x = list(mime.extensions)
x.remove(ext)
x.insert(0, ext)
mime.extensions = tuple(x)
MimeTypesRegistry.initialize = initialize
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