-
-
Notifications
You must be signed in to change notification settings - Fork 83
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
Register IObjectPrimaryFieldTarget for Link objects #1847
Conversation
…url for anonymous users
@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:
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! |
@jenkins-plone-org please run jobs |
@cekk Can you remind me where/how does that end up using the IObjectPrimaryFieldTarget adapter? |
https://github.com/plone/plone.restapi/blob/main/src/plone/restapi/serializer/dxcontent.py#L137 The first one add an attribute to the serialized json. In my usecase when you refers to a Link object and call resolve_uid with its UID, i'd like to return:
|
@cekk Thanks. I agree with the use case; it matches how we handle Links in other situations. I just needed the reminder that the resolveuid code uses this. |
Co-authored-by: David Glick <[email protected]>
This could be useful for example when you link a Link in slate.
Anonymous users automatically have resolved url in text link without redirects.
I choose to do it for anonymous users because otherwise this could change stored value in the slate data: for example if an editor of the current page can't edit the linked Link, he could override slate link data with the resolved url and not with the resolveuid link to Link object.
btw for this kind of use-cases probably could solve our problems a flag "is in edit-mode" or "is in view mode" that Volto sends to the backend and let us do different things in serializer based on that flag.
📚 Documentation preview 📚: https://plonerestapi--1847.org.readthedocs.build/