-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
Default Factory management #453
Comments
This fixed part of it: #455 However, we still need to advise the usage of it with behaviors. |
I just remember a bit the issue.. but it still feels a bit odd for me to return a default value on a GET operation (while this value is not present on the source state, db)... anyway I think it work for us. |
I remember two issues related with defaults.
class IImagesBehavior(Interface):
index_field(
"images",
field_mapping={
"type": "object",
"enabled": False, # index = False
"properties": {},
},
)
images = schema.Dict(
key_type=schema.TextLine(),
value_type=schema.TextLine(),
required=False,
default_factory=dict,
# -----^
)
@configure.behavior(
title="Images type map",
provides=IImagesBehavior,
marker=IImagesMarker,
for_=IResource,
)
class ImagesBehavior(AnnotationBehavior):
__local__properties__ = ("images",)
images = ContextProperty("images", {})
# -----^ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Default factory and default value on schema has some bugs:
In order to fix the issue I would like some feedback:
On a GET operation, the default value should not be committed and only serialized on JSON serializer module.
If we access the value on the code we should get the default value but add to the parent object if we are on a GET/HEAD operation.
The text was updated successfully, but these errors were encountered: