mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-02 00:44:52 +01:00
handle preactions moved to base handler
This commit is contained in:
parent
35db6b394e
commit
67a672f676
2 changed files with 41 additions and 46 deletions
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue