From c0582810df676c2cd91cdb6d008c15428be0dc5e Mon Sep 17 00:00:00 2001 From: Peter Mathis Date: Thu, 20 Jun 2024 10:27:55 +0200 Subject: [PATCH 1/2] Follow up to #236 do the same for `NamedImage` --- CHANGES.rst | 2 ++ src/collective/exportimport/serializer.py | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index d2481e20..d8ac2c47 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] 1.12 (2024-03-08) diff --git a/src/collective/exportimport/serializer.py b/src/collective/exportimport/serializer.py index eff23154..a7072c8e 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 @@ -617,6 +617,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) From 342c20abb5905ea5ad2022a7721041201754fe68 Mon Sep 17 00:00:00 2001 From: Peter Mathis Date: Thu, 20 Jun 2024 10:32:34 +0200 Subject: [PATCH 2/2] fix tests for py 2.7 --- setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 7c781dcf..03246913 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,6 @@ install_requires = [ "hurry.filesize", - "ijson", "setuptools", "six", ] @@ -31,6 +30,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") @@ -39,6 +40,7 @@ install_requires.append("pyrsistent < 0.16.0") else: install_requires.append("beautifulsoup4") + install_requires.append("ijson") install_requires.append("plone.api >= 1.8.4") install_requires.append("plone.restapi")