Bases: BaseHandler
Event handler listening to topics.
Output of callback is not handled and handler is not designed for actions.
By default is listening to "ftrack.update". To change it override 'register' method of change 'subscription_topic' attribute.
Source code in client/ayon_ftrack/common/event_handlers/ftrack_event_handler.py
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101 | class BaseEventHandler(BaseHandler):
"""Event handler listening to topics.
Output of callback is not handled and handler is not designed for actions.
By default is listening to "ftrack.update". To change it override
'register' method of change 'subscription_topic' attribute.
"""
__ignore_handler_class: bool = True
subscription_topic: str = "ftrack.update"
handler_type: str = "Event"
def register(self):
"""Register to subscription topic."""
self.session.event_hub.subscribe(
"topic={}".format(self.subscription_topic),
self._process,
priority=self.priority
)
def process(self, event: ftrack_api.event.base.Event):
"""Callback triggered on event with matching topic.
Args:
event (ftrack_api.Event): ftrack event to process.
"""
return self.launch(self.session, event)
def launch(
self,
session: ftrack_api.Session,
event: ftrack_api.event.base.Event
):
"""Deprecated method used for backwards compatibility.
Override 'process' method rather then 'launch'. Method name 'launch'
is derived from action event handler which does not make sense in terms
of not action based processing.
Args:
session (ftrack_api.Session): ftrack session which triggered
the event.
event (ftrack_api.Event): ftrack event to process.
"""
raise NotImplementedError()
def _process(self, event: ftrack_api.event.base.Event):
return self._launch(event)
def _launch(self, event: ftrack_api.event.base.Event):
"""Callback kept for backwards compatibility.
Will be removed when default
"""
self.session.rollback()
self.session._local_cache.clear()
try:
self.process(event)
except Exception as exc:
self.log.error(
"Event \"{}\" Failed: {}".format(
self.__class__.__name__, str(exc)
),
exc_info=True
)
self.session.rollback()
self.session._configure_locations()
def _translate_event(
self,
event: ftrack_api.event.base.Event,
session: Optional[ftrack_api.Session] = None
):
"""Receive entity objects based on event.
Args:
event (ftrack_api.Event): Event to process.
session (ftrack_api.Session): Connected ftrack session.
Returns:
List[ftrack_api.Entity]: Queried entities based on event data.
"""
return self._get_entities(
event,
session,
ignore=["socialfeed", "socialnotification", "team"]
)
|
launch(session, event)
Deprecated method used for backwards compatibility.
Override 'process' method rather then 'launch'. Method name 'launch' is derived from action event handler which does not make sense in terms of not action based processing.
Parameters:
Name | Type | Description | Default |
session | Session | ftrack session which triggered the event. | required |
event | Event | | required |
Source code in client/ayon_ftrack/common/event_handlers/ftrack_event_handler.py
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56 | def launch(
self,
session: ftrack_api.Session,
event: ftrack_api.event.base.Event
):
"""Deprecated method used for backwards compatibility.
Override 'process' method rather then 'launch'. Method name 'launch'
is derived from action event handler which does not make sense in terms
of not action based processing.
Args:
session (ftrack_api.Session): ftrack session which triggered
the event.
event (ftrack_api.Event): ftrack event to process.
"""
raise NotImplementedError()
|
process(event)
Callback triggered on event with matching topic.
Parameters:
Name | Type | Description | Default |
event | Event | | required |
Source code in client/ayon_ftrack/common/event_handlers/ftrack_event_handler.py
| def process(self, event: ftrack_api.event.base.Event):
"""Callback triggered on event with matching topic.
Args:
event (ftrack_api.Event): ftrack event to process.
"""
return self.launch(self.session, event)
|
register()
Register to subscription topic.
Source code in client/ayon_ftrack/common/event_handlers/ftrack_event_handler.py
| def register(self):
"""Register to subscription topic."""
self.session.event_hub.subscribe(
"topic={}".format(self.subscription_topic),
self._process,
priority=self.priority
)
|