diff --git a/product/ERP5/bootstrap/erp5_core/ToolTemplateItem/mimetypes_registry.xml b/product/ERP5/bootstrap/erp5_core/ToolTemplateItem/mimetypes_registry.xml index 6acce8424a14d2688ea3c5f289f9f1c691d5c48c..076472a52c07cb9f9e8934afcbcb092eeb539eed 100644 --- a/product/ERP5/bootstrap/erp5_core/ToolTemplateItem/mimetypes_registry.xml +++ b/product/ERP5/bootstrap/erp5_core/ToolTemplateItem/mimetypes_registry.xml @@ -11011,9 +11011,9 @@ <key> <string>extensions</string> </key> <value> <tuple> + <string>bin</string> <string>obj</string> <string>so</string> - <string>bin</string> <string>a</string> </tuple> </value> @@ -17635,9 +17635,9 @@ <key> <string>extensions</string> </key> <value> <tuple> + <string>jpg</string> <string>pjpg</string> <string>jpeg</string> - <string>jpg</string> <string>jpe</string> </tuple> </value> diff --git a/product/ERP5/tests/testBusinessTemplateTwoFileExport.py b/product/ERP5/tests/testBusinessTemplateTwoFileExport.py index 1cf1707425f3dd3eef06129939daf991f80fcb75..f8f3db75728f50e1913472e449645bae41d5e5af 100644 --- a/product/ERP5/tests/testBusinessTemplateTwoFileExport.py +++ b/product/ERP5/tests/testBusinessTemplateTwoFileExport.py @@ -286,7 +286,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO def test_twoFileImportExportForImageIdentifyingTypeByContentType(self): """ 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 AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO @@ -297,7 +297,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO data = image_data, content_type = "image/jpeg", portal_type = "Image", - ), '.pjpg') + ), '.jpg') def test_twoFileImportExportForImageNotIdentifyingType(self): """ @@ -356,14 +356,14 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO def test_twoFileImportExportForFileIdentifyingTypeByContentTypeObj(self): """ 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( title = "foo", data = "a test file", content_type = "application/octet-stream", portal_type = "File", - ), '.obj') + ), '.bin') def test_twoFileImportExportForFileIdentifyingTypeByContentTypeEpub(self): """ diff --git a/product/ERP5OOo/tests/testDms.py b/product/ERP5OOo/tests/testDms.py index 0150d5a2cb107492a631ac969d1658d3c081edb7..06f9c3201d50505cd3cff9a1d6f9a475140f0406 100644 --- a/product/ERP5OOo/tests/testDms.py +++ b/product/ERP5OOo/tests/testDms.py @@ -1612,7 +1612,7 @@ class TestDocument(TestDocumentMixin): image_count = builder._image_count failure_message = 'Expected image not found in ODF zipped archive' # 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) # Continue the test with image resizing support diff --git a/product/ERP5Type/ZopePatch.py b/product/ERP5Type/ZopePatch.py index bd0d636659ccbfb2bd21cccb3ddeaa9905ecbfad..5cddeb81468a810cac08ef5ee2b88e51526db999 100644 --- a/product/ERP5Type/ZopePatch.py +++ b/product/ERP5Type/ZopePatch.py @@ -86,6 +86,7 @@ from Products.ERP5Type.patches import DTMLDocument from Products.ERP5Type.patches import CMFCoreUtils from Products.ERP5Type.patches import ZopePageTemplate from Products.ERP5Type.patches import ZSQLMethod +from Products.ERP5Type.patches import MimetypesRegistry # These symbols are required for backward compatibility from Products.ERP5Type.patches.PropertyManager import ERP5PropertyManager diff --git a/product/ERP5Type/patches/MimetypesRegistry.py b/product/ERP5Type/patches/MimetypesRegistry.py new file mode 100644 index 0000000000000000000000000000000000000000..3a45fc2015b73292d6dbae6dffc414433cdf1fb7 --- /dev/null +++ b/product/ERP5Type/patches/MimetypesRegistry.py @@ -0,0 +1,18 @@ +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