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

Implement schema-intent concept #6001

Merged
merged 12 commits into from
Nov 4, 2019
Merged

Implement schema-intent concept #6001

merged 12 commits into from
Nov 4, 2019

Conversation

lukasgraf
Copy link
Member

@lukasgraf lukasgraf commented Oct 21, 2019

Implements the schema-intent concept according to #5973:

  • New intent-aware @schema endpoint
  • Customized, intent-aware@sources, @querysources and @vocabularies endpoints

Todo:

  • Slap the IDuringContentCreation interface on the request during add-intent scenarios
  • Tests. Especially one that tests default values with restricted_vocab.py
  • Check whether the expansion support for @types needs to be added to @schema as well
  • Verify that @types responses aren't broken in non-backwards compatible ways
    - [ ] Documentation

Obviously the frontend also needs to be adapted to use these new endpoints in their intent-aware ways.

elif len(self.params) == 1:
# Edit intent
# - context is the object to be edited
# - schemata need to be determined via context
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment line is not needed here

# Add intent
# - context is the container where the object will be created
# - portal_type is the type of object to be created
# - schemata need to be determined via portal_type
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment line is not needed here

# - portal_type is the type of object to be created
# - schemata need to be determined via portal_type
self.intent = 'add'
portal_type = self.params[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

portal_type is unused here

@njohner
Copy link
Contributor

njohner commented Oct 25, 2019

Current stand:

  • Added IDuringContentCreation interface in the case of add intent
  • Added tests for vocabularies, sources and querysources endpoints.

Then there were some issues with fields of the type type of the keywords which have one more level of nesting (field.value_type to get to the vocabulary):


@adapter(ICollection, Interface, IOpengeverBaseLayer)
@implementer(IJsonSchemaProvider)
class GEVERCollectionJsonSchemaProvider(CollectionJsonSchemaProvider):
Copy link
Contributor

Choose a reason for hiding this comment

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

😅 When I was looking at this issue I was thinking to myself I don't want to overwrite all these adapters, there must be some easier way....

@lukasgraf
Copy link
Member Author

This one is ready for a final review. We decided to not duplicate efforts for documentation, and create it when this finally moves upstream into plone.restapi. Also, the high-level concept is already documented quite well in the referenced issue.

@lukasgraf lukasgraf marked this pull request as ready for review November 1, 2019 11:13
Copy link
Member

@phgross phgross left a comment

Choose a reason for hiding this comment

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

Looks good to me. But there is still a WIP commit message ...

vocab_name = self.params[0]
elif len(self.params) == 2:
# Add intent
# - context is the container where the object will be created
# - portal_type is the type of object to be created, not needed here
# - first parameter is the portal_type, not needed here
Copy link
Member

Choose a reason for hiding this comment

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

not needed here ✂️ 🤔

lukasgraf and others added 12 commits November 4, 2019 11:36
Multivalued fields don't directly have sources themselves, but
their items do.

We therefore need to handle that case in the @sources and
@querysources endpoints, and look for a source on the Choice
field used as the value_type for the multivalued field.

Similarly we need to construct appropriate URLs during
schema serialization for these types of fields: The Choice
fields used as the value_type for multivalued fields don't
usually have a name. We therefore omit their empty string
name from the URL, and instead construct URLs that look
like the source was actually on the multivalued fields
themselves.
@lukasgraf
Copy link
Member Author

Updated

@lukasgraf lukasgraf merged commit c3488b0 into master Nov 4, 2019
@lukasgraf lukasgraf deleted the lg-schema-intent branch November 4, 2019 12:05
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