def bind(self, approve, get_workflow=False): self._approve = approve if get_workflow and self._approve.workflow: if not self._workflow: workflow_id = self._approve._workflow_ # restore workflow from database self._workflow = Workflow.load(workflow_id, operator=self.operator)
def create_workflow(self, start=True): # create new workflow workflow = Workflow.create(WORKFLOW_SPEC_NAME, operator=self.operator) workflow.ref_unique_id = "approve-%d" % self._approve.id if start: workflow.start() self._approve.workflow = workflow.get_id() self._approve.save() return workflow
def async_deliver(self, task_id): from redbreast.serializable import Workflow, Task task_obj = self.task_model.get(task_id) if task_obj.state == 2: #READY wf_id = task_obj._workflow_ workflow = Workflow.load(wf_id, operator=task_obj._modified_user_) task = workflow.get_task(task_obj.uuid) self.prints("------------------------------------------------") self.prints("spec %s %s(%s)" % (workflow.get_spec_name(), task.get_name(), task.get_spec_name())) message = task.deliver_msg next_tasks = task.next_tasks workflow.deliver(task_obj.uuid, message=message, next_tasks=next_tasks, async=False) task_obj.update(async_status=0) task_obj.save()
os.chdir(locate_dir) os.chdir('test_project') from uliweb.manage import make_simple_application app = make_simple_application(apps_dir='./apps') CoreWFManager.reset() storage = WFDatabaseStorage() CoreWFManager.set_storage(storage) workflow_spec = CoreWFManager.get_workflow_spec('TestWorkflow') workflow_spec.on("enter", event_log) workflow_spec.on("ready", event_log) workflow_spec.on("executed", event_log) workflow_spec.on("completed", event_log) print "--------Workflow Spec Dump ----------------------" workflow_spec.dump() print "---------RUN-------------------" workflow_id = 3 print "............", workflow_id workflow = Workflow.load(workflow_id) workflow.task_tree.dump() workflow.run()
from uliweb.manage import make_simple_application app = make_simple_application(apps_dir='./apps') CoreWFManager.reset() storage = WFDatabaseStorage() CoreWFManager.set_storage(storage) workflow_spec = CoreWFManager.get_workflow_spec('TestWorkflow') workflow_spec.on("enter", event_log) workflow_spec.on("ready", event_log) workflow_spec.on("executed", event_log) workflow_spec.on("completed", event_log) print "--------Workflow Spec Dump ----------------------" workflow_spec.dump() workflow = Workflow(workflow_spec) print "---------START-------------------" workflow.start() workflow.run_next() workflow.run_next() workflow.run_next() workflow.run_next() workflow.run_next() print "---------RUN-------------------" workflow.task_tree.dump() workflow_id = workflow.get_id() print "............", workflow_id
def event_log(event): print " --> spec %s, %s" % (event.task.get_name(), event.type) locate_dir = os.path.dirname(__file__) os.chdir(locate_dir) os.chdir('test_project') from uliweb.manage import make_simple_application app = make_simple_application(apps_dir='./apps') CoreWFManager.reset() storage = WFDatabaseStorage() CoreWFManager.set_storage(storage) workflow_spec = CoreWFManager.get_workflow_spec('TestWorkflow') workflow_spec.on("enter", event_log) workflow_spec.on("ready", event_log) workflow_spec.on("executed", event_log) workflow_spec.on("completed", event_log) print "--------Workflow Spec Dump ----------------------" workflow_spec.dump() print "---------RUN-------------------" workflow_id = 3 print "............", workflow_id workflow = Workflow.load(workflow_id) workflow.task_tree.dump() workflow.run()
app = make_simple_application(apps_dir='./apps') CoreWFManager.reset() storage = WFDatabaseStorage() CoreWFManager.set_storage(storage) workflow_spec = CoreWFManager.get_workflow_spec('TestWorkflow') workflow_spec.on("enter", event_log) workflow_spec.on("ready", event_log) workflow_spec.on("executed", event_log) workflow_spec.on("completed", event_log) print "--------Workflow Spec Dump ----------------------" workflow_spec.dump() workflow = Workflow(workflow_spec) print "---------START-------------------" workflow.start() workflow.run_next() workflow.run_next() workflow.run_next() workflow.run_next() workflow.run_next() print "---------RUN-------------------" workflow.task_tree.dump() workflow_id = workflow.get_id() print "............", workflow_id