How to create a django ViewFlow process programmatically

前端 未结 3 1513
离开以前
离开以前 2020-12-02 21:26

Synopsis

I\'m developing a web application to learn Django (python 3.4 & Django 1.6.10). The web app has complex and often updated workflows. I decided

3条回答
  •  佛祖请我去吃肉
    2020-12-02 22:02

    to start manually:

    from viewflow import flow
    from viewflow.base import this, Flow
    from .models import CIE
    from viewflow import frontend
    from django.utils.decorators import method_decorator
    
    @frontend.register
    class CIE(Flow):
        process_class = CIE
        start = flow.StartFunction(this.create_flow).Next(this.end)
        end = flow.End()
    
        @method_decorator(flow.flow_start_func)
        def create_flow(self, activation):
            activation.prepare()
            activation.done()
            return activation
    

    after that expose rpc:

    from modernrpc.core import rpc_method
    from flow.flows import CIE
    
        @rpc_method
        def start():
            CIE.start.run()
    

提交回复
热议问题