Fix inherited schema fields missing for multi-schema Dexterity types#89
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of the issue/feature this PR addresses
When the object being serialized is a Dexterity (DX) content type whose schema interface inherits from another schema interface, only the fields declared directly on the type's own interface were returned. Fields declared by the parent interface(s) were silently dropped from the API response.
The root cause was the use of
schema.names()inget_fields, which returns only the names declared directly on the interface — inherited fields requirenames(all=True).senaite.core'sapi.get_fieldsalready resolves this correctly (it usesplone.supermodel'sgetFieldsInOrder, which walks the interface bases, and also folds in behavior fields), so this PR delegates to it instead of re-implementing the field collection.senaite.core.content.supplier.Supplieris a representative multi-schema DX type: itsISupplierSchemainherits fromIOrganizationSchema.Current behavior before PR
For a multi-schema DX type, the JSON response (and
get_fields/get_field) expose only the fields declared on the leaf schema interface. Inherited fields (e.g.tax_number, declared on the parentIOrganizationSchema) are missing, so they cannot be read, searched or projected through the API.Desired behavior after PR is merged
All schema fields are returned — those declared directly on the type's interface, those inherited from parent interfaces, and those contributed by assigned behaviors.
get_fields,get_fieldand theDexterity/ATdata providers all derive their field set from a single source (senaite.core'sapi.get_fields), keeping the field list and per-field lookups consistent.--
I confirm I have tested the PR thoroughly and coded it according to PEP8
standards.