Skip to content
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

Assist developers in partial auto-updates of entities #59

Open
simontaurus opened this issue Jul 3, 2024 · 0 comments
Open

Assist developers in partial auto-updates of entities #59

simontaurus opened this issue Jul 3, 2024 · 0 comments
Assignees

Comments

@simontaurus
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants