我想完全通过代码来运行我的进程。我已经设法启动了一个进程,但是我不能运行进程的下一部分。我试着使用"flow.Function“并调用我想要的函数,但我没有说
'Function {} should be called with task instance', 'execute'" 关于这个主题的文档也不是很清楚。
flows.py
@flow.flow_start_func
def create_flow(activation, campos_proceso, **kwargs):
activation.process.asignador = campos_proceso['asignador']
activation.process.ejecutor = campos_proceso['ejecutor']
activation.process.tipo_de_flujo = campos_proceso['tipo_de_flujo']
activation.process.estado_del_entregable = campos_proceso[
'estado_del_entregable']
activation.process.save()
activation.prepare()
activation.done()
return activation
@flow.flow_func
def exec_flow(activation, process_fields, **kwargs):
activation.process.revisor = process_fields['revisor']
activation.process.save()
activation.prepare()
activation.done()
return activation
@frontend.register
class Delivery_flow(Flow):
process_class = DeliveryProcess
start = flow.StartFunction(create_flow).Next(this.execute)
execute = flow.Function(exec_flow).Next(this.end)
end = flow.End()views.py
def Execute(request): #campos_ejecucion, request):
campos_ejecucion = {
'ejecutor':request.user,
'revisor':request.user,
'observaciones_ejecutor':'Este es un puente magico',
'url_ejecucion':'https://www.youtube.com/watch?v=G-yNGb0Q91Y',
}
campos_proceso = {
'revisor':campos_ejecucion['revisor']
}
flows.Delivery_flow.execute.run()
Entregable.objects.crear_entregable()
return render(request, "Flujo/landing.html")发布于 2019-03-25 20:40:07
通常,“完全由代码运行”是反模式,应该避免。Flow类是一组与URL绑定的视图,因此它类似于基于类的URL配置,您不需要再增加一个单独的视图和URL条目。
对于自定义视图,您可以查看食谱示例- https://github.com/viewflow/cookbook/blob/master/custom_views/demo/bloodtest/views.py
至于实际的问题,您已经错过了task_loader。功能节点应该找出实际执行的是什么任务。您可以在流层(使用task_loader)执行此操作,也可以直接获取任务模型实例并将其作为函数参数传递- http://docs.viewflow.io/viewflow_flow_nodes.html#viewflow.flow.Function
https://stackoverflow.com/questions/55248306
复制相似问题