-
-
Notifications
You must be signed in to change notification settings - Fork 78
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
Revisit improve support for zope.schema default
and missing_value
if present
#1290
base: main
Are you sure you want to change the base?
Revisit improve support for zope.schema default
and missing_value
if present
#1290
Conversation
Co-authored-by: Jens W. Klein <jk@kleinundpartner.at>
… defaults and defaultFactory
@sneridagh thanks for creating this Pull Request and help improve Plone! To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass. Whenever you feel that the pull request is ready to be tested, either start all jenkins jobs pull requests by yourself, or simply add a comment in this pull request stating:
With this simple comment all the jobs will be started automatically. Happy hacking! |
Proof that we are not handling defaults ^^^ |
default
and missing_value
if present
Ok, I drop here the the definition of both first - I need to wrap my head around the whole... Whether or not the field is required A value designated as missing While Python’s None is the most likely value to signify ‘missing’, some fields may use different values. For example, it is common for text fields to use the empty string (‘’) to signify that a value is missing. Numeric fields may use 0 or -1 instead of None as their missing value. A field that is ‘required’ signifies that missing values are invalid and should not be assigned A default value |
missing = "I'm empty but here's my value". I can understand the case where you're creating an object, it comes with a default value, but then the user decides that the default value is wrong and instead "empty" should be the real value. But what is actually the use case for missing? It seems to me that "missing = default" would seem like the sane value all the time. |
Story:
Volto only sends the "Changed" values to p.restapi, so it doesn't has to send (and set) over and over again all the content type data. Then,
zope.schema
default
andmissing_value
are not observed correctly.Since it was a "hidden" problem, people tended to use
default
whenever necessary, when in fact, they really wanted to meanmissing_value
. In some fields like List-ish fields, that lead to a "Constrain not satisfied" error, forcing the developer to misusedefault
.This PR tries to fix the problem. #1283 tried to fix it, improving and adding proper support in p.restapi for them. However, in the wild, there are combinations of
default
andmissing_value
that are not consistent or non-sense that broke the overall deserialisation for these kind of fields.Language (Dublin Core)
This is how the
language
field is defined inplone.app.dexterity
:It has both a
defaultFactory
AND amissing_value
. Also,missing_value
is a null-ish/false-ish value, which are always complex to handle.Defaults must have precedence over
missing_value
and take into account null-ish/false-ish values.The code gets hairy, and complex, but having defaults and missing_values out of the equation is not good for RESTAPI, so we need to find the correct implementation and a good set of tests/QA and a dozen of eyes over it.
Leaving this here, so we can handle it whenever we have time. But for sure it's a sprint level endeavour.