diff --git a/CHANGES.rst b/CHANGES.rst index 134dc6df..9e32e964 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -7,6 +7,8 @@ Changelog - Add and run a black version, that is compatible with Python 2. [pgrunewald] +- Fix ``AtributeError: 'NamedImage' object has no attribute '_blob'`` similar to #236. + [petschki] - Make zcml conditions more specific so that migration aliases don't trigger them [reinhardt] diff --git a/setup.py b/setup.py index 1c4cdcb9..6b23ef55 100644 --- a/setup.py +++ b/setup.py @@ -31,6 +31,8 @@ install_requires.append("jsonschema < 4") install_requires.append("pathlib2") install_requires.append("plone.api >= 1.8.4, < 2") + + install_requires.append("ijson < 3.3.0") # There is a py2-imcompatibility in plone.rest 3.0.1 install_requires.append("plone.rest < 3.0.1") install_requires.append("plone.restapi < 8") diff --git a/src/collective/exportimport/serializer.py b/src/collective/exportimport/serializer.py index 2530d426..c9892ec9 100644 --- a/src/collective/exportimport/serializer.py +++ b/src/collective/exportimport/serializer.py @@ -7,7 +7,7 @@ from hurry.filesize import size from plone.app.textfield.interfaces import IRichText from plone.dexterity.interfaces import IDexterityContent -from plone.namedfile.interfaces import INamedFileField, INamedBlobFileField +from plone.namedfile.interfaces import INamedFileField, INamedBlobFileField, INamedImageField, INamedBlobImageField from plone.namedfile.interfaces import INamedImageField from plone.restapi.behaviors import IBlocks from plone.restapi.interfaces import IFieldSerializer @@ -619,6 +619,15 @@ def __call__(self): @adapter(INamedImageField, IDexterityContent, IPathBlobsMarker) @implementer(IFieldSerializer) +class ImageFieldSerializerZODBData(ImageFieldSerializerWithBlobs): + """Although the marker is IPathBlobsMarker, this being a plain NamedImage + object, its data is in the ZODB, thus this still needs to be + base64 encoded into the JSON file + So we just subclass from the above ImageFieldSerializerWithBlobs""" + + +@adapter(INamedBlobImageField, IDexterityContent, IPathBlobsMarker) +@implementer(IFieldSerializer) class ImageFieldSerializerWithBlobPaths(DefaultFieldSerializer): def __call__(self): image = self.field.get(self.context)