Repository navigation
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. |
|
@sneridagh Should we keep this one open? |
Documentation build overview
|
|
@ericof TBH, if in 5 years we did not care about it... I think it popped while trying to work different combinations... |
|
Thanks for this, @sneridagh. I merged The problem is real, and the
If we pick this up again, I'd do it as a fresh PR on current |
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.schemadefaultandmissing_valueare not observed correctly.Since it was a "hidden" problem, people tended to use
defaultwhenever 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
defaultandmissing_valuethat are not consistent or non-sense that broke the overall deserialisation for these kind of fields.Language (Dublin Core)
This is how the
languagefield is defined inplone.app.dexterity:It has both a
defaultFactoryAND amissing_value. Also,missing_valueis a null-ish/false-ish value, which are always complex to handle.Defaults must have precedence over
missing_valueand 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.