From 6ea15d2bfe76caa29095d6c340c240d1783279ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 15 Apr 2016 15:07:00 +0200 Subject: [PATCH] No need to manually keep track of index. --- blender_cloud/attract/__init__.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/blender_cloud/attract/__init__.py b/blender_cloud/attract/__init__.py index 90534cc..68e2547 100644 --- a/blender_cloud/attract/__init__.py +++ b/blender_cloud/attract/__init__.py @@ -336,8 +336,7 @@ class AttractShotsOrderUpdate(AttractOperatorMixin, Operator): strips_with_atc_object_id.sort( key=lambda strip: strip.frame_start + strip.frame_offset_start) - index = 1 - for strip in strips_with_atc_object_id: + for index, strip in enumerate(strips_with_atc_object_id): """ # Currently we use the code below to force update all nodes. # Check that the shot is in the list of retrieved shots @@ -353,12 +352,10 @@ class AttractShotsOrderUpdate(AttractOperatorMixin, Operator): # We get all nodes one by one. This is bad and stupid. try: shot_node = pillar.call(Node.find, strip.atc_object_id) - # if shot_node.properties.order != index: - shot_node.order = index - shot_node.update() + shot_node.order = index + 1 + pillar.call(shot_node.update) print('{0} - updating {1}'.format(shot_node.order, shot_node.name)) strip.atc_order = index - index += 1 except ResourceNotFound: # Reset the attract properties for any shot not found on the server # print("Error: shot {0} not found".format(strip.atc_object_id))