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 for parent summary serializer when the parent has a but it's empty #148

Merged
merged 5 commits into from
May 1, 2024

Conversation

sneridagh
Copy link
Member

@sneridagh sneridagh commented Apr 29, 2024

I tried it in a project with content (Document) having preview_image_link behavior, and it broke when creating childs because the parent has the empty field, and it tried to access to_object on it.

https://github.com/kitconcept/kitconcept.com/actions/runs/8846612966/job/24369069918?pr=145#step:7:912

"traceback": [
    "File \"/app/lib/python3.11/site-packages/ZPublisher/WSGIPublisher.py\", line 181, in transaction_pubevents",
    "    yield",
    "",
    "  File \"/app/lib/python3.11/site-packages/ZPublisher/WSGIPublisher.py\", line 391, in publish_module",
    "    response = _publish(request, new_mod_info)",
    "               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^",
    "",
    "  File \"/app/lib/python3.11/site-packages/ZPublisher/WSGIPublisher.py\", line 285, in publish",
    "    result = mapply(obj,",
    "             ^^^^^^^^^^^",
    "",
    "  File \"/app/lib/python3.11/site-packages/ZPublisher/mapply.py\", line 98, in mapply",
    "    return debug(object, args, context)",
    "           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^",
    "",
    "  File \"/app/lib/python3.11/site-packages/ZPublisher/WSGIPublisher.py\", line 68, in call_object",
    "    return obj(*args)",
    "           ^^^^^^^^^^",
    "",
    "  File \"/app/lib/python3.11/site-packages/plone/rest/service.py\", line 21, in __call__",
    "    return self.render()",
    "           ^^^^^^^^^^^^^",
    "",
    "  File \"/app/lib/python3.11/site-packages/plone/restapi/services/__init__.py\", line 19, in render",
    "    content = self.reply()",
    "              ^^^^^^^^^^^^",
    "",
    "  File \"/app/lib/python3.11/site-packages/plone/restapi/services/content/add.py\", line 115, in reply",
    "    serialized_obj = serializer()",
    "                     ^^^^^^^^^^^^",
    "",
    "  File \"/app/lib/python3.11/site-packages/plone/restapi/serializer/dxcontent.py\", line 178, in __call__",
    "    folder_metadata = super().__call__(version=version)",
    "                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^",
    "",
    "  File \"/app/lib/python3.11/site-packages/plone/restapi/serializer/dxcontent.py\", line 76, in __call__",
    "    parent_summary = getMultiAdapter(",
    "                     ^^^^^^^^^^^^^^^^",
    "",
    "  File \"/app/lib/python3.11/site-packages/plone/restapi/serializer/summary.py\", line 99, in __call__",
    "    value = value()",
    "            ^^^^^^^",
    "",
    "  File \"/app/lib/python3.11/site-packages/plone/app/contentlisting/realobject.py\", line 113, in image_scales",
    "    return getMultiAdapter((obj, self.request), IImageScalesAdapter)()",
    "           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^",
    "",
    "  File \"/app/lib/python3.11/site-packages/Products/CMFPlone/image_scales/adapters.py\", line 30, in __call__",
    "    scales = serializer()",
    "             ^^^^^^^^^^^^",
    "",
    "  File \"/app/lib/python3.11/site-packages/plone/volto/behaviors/preview_link.py\", line 59, in __call__",
    "    linked_image = value.to_object",
    "                   ^^^^^^^^^^^^^^^"
  ],
  "type": "AttributeError"
}

Problem: this is in 6.0.11 :(

Also, changed the order of the condition in the image_field index. Since the most probably is that you change from the default, existing, preview_image to the preview_image_link, is more sane to check the latter first, then the default.

@sneridagh sneridagh requested a review from davisagli April 29, 2024 13:57
@mister-roboto
Copy link

@sneridagh thanks for creating this Pull Request and helping to improve Plone!

TL;DR: Finish pushing changes, pass all other checks, then paste a comment:

@jenkins-plone-org please run jobs

To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass, but it takes 30-60 min. Other CI checks are usually much faster and the Plone Jenkins resources are limited, so when done pushing changes and all other checks pass either start all Jenkins PR jobs yourself, or simply add the comment above in this PR to start all the jobs automatically.

Happy hacking!

@sneridagh
Copy link
Member Author

@jenkins-plone-org please run jobs

@sneridagh
Copy link
Member Author

@jenkins-plone-org please run jobs

@sneridagh
Copy link
Member Author

@davisagli ready

news/148.bugfix Outdated Show resolved Hide resolved
@davisagli davisagli merged commit dffae07 into main May 1, 2024
13 of 17 checks passed
@davisagli davisagli deleted the fiximagescalesserializer branch May 1, 2024 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants