Ejemplo n.º 1
0
    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 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()
Ejemplo n.º 3
0
    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()


        
Ejemplo n.º 5
0
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()