Skip to content

Commit

Permalink
Follow up to #236 do the same for NamedImage
Browse files Browse the repository at this point in the history
  • Loading branch information
petschki committed Jun 20, 2024
1 parent 6f8834b commit c058281
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 10 additions & 1 deletion src/collective/exportimport/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c058281

Please sign in to comment.