diff --git a/pype/ftrack/lib/ftrack_app_handler.py b/pype/ftrack/lib/ftrack_app_handler.py index d35f6e003f..216298799d 100644 --- a/pype/ftrack/lib/ftrack_app_handler.py +++ b/pype/ftrack/lib/ftrack_app_handler.py @@ -128,52 +128,6 @@ class AppAction(BaseHandler): self.session, response, *args ) - - def _handle_preactions(self, session, event): - # If no selection - selection = event.get('data', {}).get('selection', None) - if (selection is None): - return False - # If preactions are not set - if ( - not hasattr(self, 'preactions') and - self.preactions is None and - len(self.preactions) < 1 - ): - return True - # If preactions were already started - if event['data'].get('preactions_launched', None) is True: - return True - - # Launch preactions - for preaction in self.preactions: - event = ftrack_api.event.base.Event( - topic='ftrack.action.launch', - data=dict( - actionIdentifier=preaction, - selection=selection - ), - source=dict( - user=dict(username=session.api_user) - ) - ) - session.event_hub.publish(event, on_error='ignore') - # Relaunch this action - event = ftrack_api.event.base.Event( - topic='ftrack.action.launch', - data=dict( - actionIdentifier=self.identifier, - selection=selection, - preactions_launched=True - ), - source=dict( - user=dict(username=session.api_user) - ) - ) - session.event_hub.publish(event, on_error='ignore') - - return False - def launch(self, session, entities, event): '''Callback method for the custom action. diff --git a/pype/ftrack/lib/ftrack_base_handler.py b/pype/ftrack/lib/ftrack_base_handler.py index 67718b5519..b03ff68a1e 100644 --- a/pype/ftrack/lib/ftrack_base_handler.py +++ b/pype/ftrack/lib/ftrack_base_handler.py @@ -284,6 +284,47 @@ class BaseHandler(object): ''' raise NotImplementedError() + def _handle_preactions(self, session, event): + # If preactions are not set + if len(self.preactions) == 0: + return True + # If no selection + selection = event.get('data', {}).get('selection', None) + if (selection is None): + return False + # If preactions were already started + if event['data'].get('preactions_launched', None) is True: + return True + + # Launch preactions + for preaction in self.preactions: + event = ftrack_api.event.base.Event( + topic='ftrack.action.launch', + data=dict( + actionIdentifier=preaction, + selection=selection + ), + source=dict( + user=dict(username=session.api_user) + ) + ) + session.event_hub.publish(event, on_error='ignore') + # Relaunch this action + event = ftrack_api.event.base.Event( + topic='ftrack.action.launch', + data=dict( + actionIdentifier=self.identifier, + selection=selection, + preactions_launched=True + ), + source=dict( + user=dict(username=session.api_user) + ) + ) + session.event_hub.publish(event, on_error='ignore') + + return False + def _interface(self, *args): interface = self.interface(*args) if interface: