Skip to content

Assist developers in partial auto-updates of entities #59

Open
@simontaurus

Description

@simontaurus

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

osw-python/src/osw/core.py

Lines 402 to 416 in 13c7af3

os.system(
f"{exec_path} \
--input {schema_path} \
--input-file-type jsonschema \
--output {temp_model_path} \
--base-class osw.model.static.OswBaseModel \
--use-default \
--enum-field-as-literal all \
--use-title-as-name \
--use-schema-description \
--use-field-description \
--encoding utf-8 \
--use-double-quotes \
--collapse-root-models \
--reuse-model \
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"]

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions