Commit 742a126a authored by payno's avatar payno
Browse files

add call to process_pre_trigger and process_post trigger for actors

parent 4a5e9b96
......@@ -24,6 +24,9 @@ __license__ = "MIT"
__date__ = "28/05/2019"
import logging
from pypushflow.addon import utils
from pypushflow.addon.classes import BaseActorAddOn
logger = logging.getLogger('pypushflow')
......@@ -40,6 +43,10 @@ class AbstractActor(object):
self.parent = parent
self.actorId = None
self._add_ons = []
for add_on_class in self._getAddOnsClasses():
self._add_ons.append(add_on_class())
def connect(self, actor):
logger.debug('Connecting actor "{0}" to actor "{1}"'.format(
self.name, actor.name
......@@ -51,7 +58,9 @@ class AbstractActor(object):
logger.debug('In actor "{0}", triggering actor "{1}"'.format(
self.name, actor.name
))
self._process_pre_trigger_add_on(inData)
actor.trigger(inData)
self._process_post_trigger_add_on()
def getActorPath(self):
return self.parent.getActorPath()
......@@ -59,3 +68,20 @@ class AbstractActor(object):
def get_addons(self):
"""Return the list of add-on that will be apply to this actor"""
raise NotImplementedError()
def _process_post_trigger_add_on(self):
for add_on in self._add_ons:
add_on.post_trigger_action(actor=self)
def _process_pre_trigger_add_on(self, in_data):
for add_on in self._add_ons:
add_on.pre_trigger_action(actor=self, in_data=in_data)
def _getAddOnsClasses(self):
add_ons = []
for _, classes in utils.get_registered_add_ons_classes().items():
for class_ in classes:
import inspect
if BaseActorAddOn in (inspect.getmro(class_)):
add_ons.append(class_)
return add_ons
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment