Commit d69ab181 authored by payno's avatar payno
Browse files

[add-on] add _BaseWorkflow whiwh should manage the add-on of the workflow

parent ac6d9542
...@@ -31,18 +31,37 @@ from pypushflow.PythonActor import PythonActor as ActorFactory ...@@ -31,18 +31,37 @@ from pypushflow.PythonActor import PythonActor as ActorFactory
from pypushflow.StartActor import StartActor from pypushflow.StartActor import StartActor
from pypushflow.StopActor import StopActor from pypushflow.StopActor import StopActor
from pypushflow.JoinActor import JoinUntilStopSignal from pypushflow.JoinActor import JoinUntilStopSignal
from pypushflow.addon import utils
from pypushflow.addon.classes import BaseWorkflowAddOn
logger = logging.getLogger('pypushflow') logger = logging.getLogger('pypushflow')
class Workflow(object): class _BaseWorkflow:
#from pypushflow import UtilsMongoDb def __init__(self, configuration):
self._configuration = configuration or {}
self._add_ons = []
for add_on_class in self._getAddOnsClasses():
self._add_ons.append(add_on_class(workflow=self,
configuration=configuration))
def _getAddOnsClasses(self):
add_ons = []
for _, classes in utils.get_registered_add_ons_classes().items():
for class_ in classes:
import inspect
if BaseWorkflowAddOn in (inspect.getmro(class_)):
add_ons.append(class_)
return add_ons
class Workflow(_BaseWorkflow):
"""TODO"""
def __init__(self, name): def __init__(self, name):
super(Workflow, self).__init__()
self.name = name self.name = name
self.listOnErrorActor = [] self.listOnErrorActor = []
#self.mongoId = UtilsMongoDb.initMongo(name=name)
def connectOnError(self, actor): def connectOnError(self, actor):
logger.debug("In connectOnError in subModule {0}, actor name {1}".format(self.name, actor.name)) logger.debug("In connectOnError in subModule {0}, actor name {1}".format(self.name, actor.name))
...@@ -58,8 +77,16 @@ class Workflow(object): ...@@ -58,8 +77,16 @@ class Workflow(object):
return '/' + self.name return '/' + self.name
class ProcessableWorkflow: class ProcessableWorkflow(_BaseWorkflow):
def __init__(self, scheme): """Define a workflow that can be executed
:param scheme: the workflow scheme
:param configuration: some configuration / settings that can be pass to
the add-on.
"""
def __init__(self, scheme, configuration=None):
super(ProcessableWorkflow, self).__init__(configuration=configuration)
assert isinstance(scheme, Scheme) assert isinstance(scheme, Scheme)
self._representation = scheme self._representation = scheme
# first load node handlers if any # first load node handlers if any
......
Supports Markdown
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