Skip to content

Commit 6a498f6

Browse files
committed
change how EntityData work
1 parent e9b7fe1 commit 6a498f6

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

ayon_api/entity_hub.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,10 @@ class EntityData(dict):
14181418
"""
14191419
def __init__(self, *args, **kwargs) -> None:
14201420
super().__init__(*args, **kwargs)
1421-
self._orig_data = copy.deepcopy(self)
1421+
self._orig_data = {
1422+
key: copy.deepcopy(value)
1423+
for key, value in self.items()
1424+
}
14221425

14231426
def get_changes(self) -> dict[str, Any]:
14241427
"""Changes in entity data.
@@ -1437,10 +1440,10 @@ def get_changes(self) -> dict[str, Any]:
14371440
output[key] = None
14381441
elif key not in self._orig_data:
14391442
# New value was set
1440-
output[key] = self[key]
1443+
output[key] = copy.deepcopy(self[key])
14411444
elif self[key] != self._orig_data[key]:
14421445
# Value was changed
1443-
output[key] = self[key]
1446+
output[key] = copy.deepcopy(self[key])
14441447
return output
14451448

14461449
def get_new_entity_value(self) -> dict[str, AttributeValueType]:
@@ -1460,7 +1463,21 @@ def get_new_entity_value(self) -> dict[str, AttributeValueType]:
14601463
def lock(self) -> None:
14611464
"""Lock changes of entity data."""
14621465

1463-
self._orig_data = copy.deepcopy(self)
1466+
orig_data = {}
1467+
for key, value in self.items():
1468+
try:
1469+
key = copy.deepcopy(key)
1470+
except RecursionError:
1471+
print(f"Failed to create copy of key '{key}'!!!")
1472+
raise
1473+
1474+
try:
1475+
orig_data[key] = copy.deepcopy(value)
1476+
except RecursionError:
1477+
print(f"Failed to create copy of value '{key}'!!!")
1478+
raise
1479+
1480+
self._orig_data = orig_data
14641481

14651482

14661483
class BaseEntity(ABC):

0 commit comments

Comments
 (0)