Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AtributeError: 'NamedImage' object has no attribute '_blob' #244

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

install_requires = [
"hurry.filesize",
"ijson",
"setuptools",
"six",
]
Expand All @@ -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")
Expand All @@ -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")

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
Loading