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

Do not change request during serialization of relation fields #1845

Merged
merged 2 commits into from
Nov 20, 2024

Conversation

cekk
Copy link
Member

@cekk cekk commented Nov 20, 2024

Serializer should not change current request.
I cloned it to allow adding UID to the data and not touching original request.


📚 Documentation preview 📚: https://plonerestapi--1845.org.readthedocs.build/

@mister-roboto
Copy link

@cekk 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!

@cekk
Copy link
Member Author

cekk commented Nov 20, 2024

@jenkins-plone-org please run jobs

Copy link
Member

@davisagli davisagli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix.

It would be nice if the __call__ method of the ISerializeToJsonSummary adapter took an optional parameter to override the metadata_fields, so that it would not need to be passed via the request. But, this is not easily backwards compatible. So I'll accept your fix.

)
]
self.serialize("test_relationchoice_field", doc2)
self.assertEqual(self.request.form["metadata_fields"], ["foo", "bar"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be slightly preferable to use real metadata names and check that they are present in the serialized object (in other words, test the result, not the implementation)

@davisagli davisagli merged commit 694ec89 into main Nov 20, 2024
21 of 25 checks passed
@davisagli davisagli deleted the cekk_fix_relationfield_serializer branch November 20, 2024 23:30
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