mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
use _commit_changes in current implementation
This commit is contained in:
parent
0894f272de
commit
3251401da3
1 changed files with 6 additions and 31 deletions
|
|
@ -332,6 +332,7 @@ class PushFrameValuesToTaskEvent(BaseEvent):
|
||||||
session, attr_ids, entity_ids, task_entity_ids, hier_attrs
|
session, attr_ids, entity_ids, task_entity_ids, hier_attrs
|
||||||
)
|
)
|
||||||
|
|
||||||
|
changes = []
|
||||||
for entity_id, current_values in current_values_by_id.items():
|
for entity_id, current_values in current_values_by_id.items():
|
||||||
parent_id = parent_id_by_task_id.get(entity_id)
|
parent_id = parent_id_by_task_id.get(entity_id)
|
||||||
if not parent_id:
|
if not parent_id:
|
||||||
|
|
@ -356,39 +357,13 @@ class PushFrameValuesToTaskEvent(BaseEvent):
|
||||||
if new_value == old_value:
|
if new_value == old_value:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
entity_key = collections.OrderedDict()
|
changes.append({
|
||||||
entity_key["configuration_id"] = attr_id
|
"new_value": new_value,
|
||||||
entity_key["entity_id"] = entity_id
|
"attr_id": attr_id,
|
||||||
self._cached_changes.append({
|
|
||||||
"attr_key": attr_key,
|
|
||||||
"entity_id": entity_id,
|
"entity_id": entity_id,
|
||||||
"value": new_value,
|
"attr_key": attr_key
|
||||||
"time": datetime.datetime.now()
|
|
||||||
})
|
})
|
||||||
if new_value is None:
|
self._commit_changes(session, changes)
|
||||||
op = ftrack_api.operation.DeleteEntityOperation(
|
|
||||||
"CustomAttributeValue",
|
|
||||||
entity_key
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
op = ftrack_api.operation.UpdateEntityOperation(
|
|
||||||
"ContextCustomAttributeValue",
|
|
||||||
entity_key,
|
|
||||||
"value",
|
|
||||||
ftrack_api.symbol.NOT_SET,
|
|
||||||
new_value
|
|
||||||
)
|
|
||||||
|
|
||||||
session.recorded_operations.push(op)
|
|
||||||
self.log.info((
|
|
||||||
"Changing Custom Attribute \"{}\" to value"
|
|
||||||
" \"{}\" on entity: {}"
|
|
||||||
).format(attr_key, new_value, entity_id))
|
|
||||||
try:
|
|
||||||
session.commit()
|
|
||||||
except Exception:
|
|
||||||
session.rollback()
|
|
||||||
self.log.warning("Changing of values failed.", exc_info=True)
|
|
||||||
|
|
||||||
def filter_changes(
|
def filter_changes(
|
||||||
self, session, event, entities_info, interest_attributes
|
self, session, event, entities_info, interest_attributes
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue