viur-framework / viur-core

The core component of ViUR, the Python framework for modern web development.
https://www.viur.dev
MIT License
13 stars 14 forks source link

Implement `has_changed` flag in bones and Skeletons #1123

Open sveneberth opened 5 months ago

sveneberth commented 5 months ago

After I assign a different value to bone, this boolean flag should be True, otherwise it should stay False. This should help to find out whether a skeleton should be saved or whether it has not been changed.

But they should be real changes.

If the skeletons value is already ["foo", "bar"] (multiple StringBone), and I call setBoneValue(["foo", "bar"]), that should not be a change. Likewise, in a multilang bone with {"de": "foo", "en": "bar"} and the languages de, fr, en, setBoneValue({"de": "foo", "en": "bar", "nl": "baz"}) should not lead to any change, as nl is new but not relevant for this bone.

phorward commented 5 months ago

Skeleton.toDB() builds a change_list, see https://github.com/viur-framework/viur-core/blob/main/src/viur/core/skeleton.py#L987. Maybe this goes into the direction of what you need.

phorward commented 5 months ago

Refers to #630 as well.