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: get schemata defined in the context #1796

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft

Conversation

mamico
Copy link
Member

@mamico mamico commented Jul 9, 2024

get schemata for behaviors defined in the context. ie using a plone.dexterity.behavior.DexterityBehaviorAssignable adapter

see https://github.com/collective/collective.instancebehavior/

@mister-roboto

This comment was marked as resolved.

Copy link

netlify bot commented Jul 9, 2024

Deploy Preview for plone-restapi canceled.

Name Link
🔨 Latest commit a683f97
🔍 Latest deploy log https://app.netlify.com/sites/plone-restapi/deploys/6694b8f2777f7b00082d3f9f

plone-6.0.x.cfg Outdated Show resolved Hide resolved
Copy link
Contributor

@stevepiercy stevepiercy left a comment

Choose a reason for hiding this comment

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

Fingers crossed!

plone-6.0.x.cfg Outdated Show resolved Hide resolved
@mamico mamico marked this pull request as ready for review October 9, 2024 22:48
@mamico
Copy link
Member Author

mamico commented Oct 9, 2024

@jenkins-plone-org please run jobs

@mamico
Copy link
Member Author

mamico commented Oct 9, 2024

@jenkins-plone-org please run jobs

Copy link
Contributor

@stevepiercy stevepiercy left a comment

Choose a reason for hiding this comment

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

Fixes for news items only. This PR needs a review from a maintainer.

news/1796.bugfix Outdated Show resolved Hide resolved
news/1796.bugfix Outdated Show resolved Hide resolved
Copy link
Contributor

@stevepiercy stevepiercy left a comment

Choose a reason for hiding this comment

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

LGTM, but this still needs a review from a maintainer. Thank you!

if fti.id == context.portal_type:
additional_schemata = tuple(getAdditionalSchemata(context=context))
else:
additional_schemata = tuple(getAdditionalSchemata(portal_type=fti.id))
Copy link
Member

Choose a reason for hiding this comment

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

@mamico Can you help me understand the logic here? What is the scenario where we can't or shouldn't pass the context?

Copy link
Member Author

@mamico mamico Oct 17, 2024

Choose a reason for hiding this comment

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

@davisagli thanks for asking for clarification and putting me doubts...

The api is called to know the schema at the creation of a new CT or to know the schema at the modification of a content. In the first case I expected it to always be called from the root of the portal (but I'm wrong), in the second case it is called from the context of the object, and it would be useful to request the schema by passing the context.

So currently it is called (ie by Volto) as:
/++api++/@types/Document creation in the root
/++api++/folder/@types/Document creation in a folder
/++api++/folder/doc1/@types/Document modification of /folder/doc1

... but also ...

/++api++/folder/doc1/@types/Document to the creation of a new document inside doc1

... here the modification I proposed behaves incorrectly (doc1.portal_type is equal to Document but the correct schema is the generic schema, not the contextual).

I am putting the PR back in draft because it needs to be rethought in some way.

Suggestions?

Copy link
Member

Choose a reason for hiding this comment

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

@mamico It's important to get the schema for new content items in the context of its container, because some vocabularies might be context-dependent. (i.e. a list of keywords that depends on what section you are in)

So maybe we need a parameter so that the schema can be requested with or without context-dependent behaviors. Then they could be included by default, but the add form could request it without this.

@mamico mamico marked this pull request as draft October 17, 2024 07:19
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.

4 participants