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

feat: Add serialize_compute and unserialize_compute to BaseBone #1145

Merged
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Sven Eberth <mail@sveneberth.de>
ArneGudermann and sveneberth authored May 7, 2024
commit a797843e7d128dde45e6fe8edb48df6af57d33f1
4 changes: 2 additions & 2 deletions src/viur/core/bones/base.py
Original file line number Diff line number Diff line change
@@ -685,7 +685,7 @@ def serialize(self, skel: 'SkeletonInstance', name: str, parentIndexed: bool) ->
return True
return False

def serialize_compute(self, skel, name):
def serialize_compute(self, skel: "SkeletonInstance", name: str) -> None:
# Handle compute on write
if self.compute:
match self.compute.interval.method:
@@ -819,7 +819,7 @@ def unserialize(self, skel: 'viur.core.skeleton.SkeletonInstance', name: str) ->
skel.accessedValues[name] = res
return True

def unserialize_compute(self, skel, name, loaded_value):
def unserialize_compute(self, skel: "SkeletonInstance", name: str, loaded_value: t.Any) -> None:
# Is this value computed?
# In this case, check for configured compute method and if recomputation is required.
# Otherwise, the value from the DB is used as is.