Open simontaurus opened 1 month ago
Idea: A script should only update fields that are hidden or readOnly, otherwise user edits get lost.
Implementation
code-generator https://github.com/koxudaxi/datamodel-code-generator?tab=readme-ov-file#all-command-options with --field-include-all-keys at this location https://github.com/OpenSemanticLab/osw-python/blob/13c7af3dd5c21f03b1725fd2c41923e94c353628/src/osw/core.py#L402-L416 creates, e.g., uuid: UUID = Field(default_factory=uuid4, options={"hidden": True}, title="UUID") accessable through model.Entity.__fields__["uuid"].field_info.extra["options"]["hidden"]
--field-include-all-keys
uuid: UUID = Field(default_factory=uuid4, options={"hidden": True}, title="UUID")
model.Entity.__fields__["uuid"].field_info.extra["options"]["hidden"]
Override of __setattribute__ (s. a. https://github.com/OO-LD/oold-python/blob/74e4f4c417184d45bc3d8bad7bb98a91cad25061/src/oold/drafts/magic_field.py#L35) could check if the field is readOnly or hidden and allow writes only in this case
__setattribute__
Idea: A script should only update fields that are hidden or readOnly, otherwise user edits get lost.
Implementation
code-generator https://github.com/koxudaxi/datamodel-code-generator?tab=readme-ov-file#all-command-options with
--field-include-all-keys
at this location https://github.com/OpenSemanticLab/osw-python/blob/13c7af3dd5c21f03b1725fd2c41923e94c353628/src/osw/core.py#L402-L416 creates, e.g.,uuid: UUID = Field(default_factory=uuid4, options={"hidden": True}, title="UUID")
accessable throughmodel.Entity.__fields__["uuid"].field_info.extra["options"]["hidden"]
Override of
__setattribute__
(s. a. https://github.com/OO-LD/oold-python/blob/74e4f4c417184d45bc3d8bad7bb98a91cad25061/src/oold/drafts/magic_field.py#L35) could check if the field is readOnly or hidden and allow writes only in this case