def add_node(workflow, name, node_type, parents, attrs={}):
 NodeClass = NODE_TYPES[node_type]
 node = NodeClass(workflow=workflow, node_type=node_type, name=name)
 for attr in attrs:
  setattr(node, attr, attrs[attr])
 node.save()
 if parents:
  for parent in parents:
   name = 'ok'
   if ((parent.node_type == 'start') or (parent.node_type == 'join')):
    name = 'to'
   elif ((parent.node_type == 'fork') or (parent.node_type == 'decision')):
    name = 'start'
   link = Link(parent=parent, child=node, name=name)
   link.save()
 if ((node_type != 'fork') and (node_type != 'decision') and (node_type != 'join')):
  link = Link(parent=node, child=Kill.objects.get(name='kill', workflow=workflow), name='error')
 link.save()
 return node

def add_node ( workflow , name , node_type , parents , attrs = { } ) : NodeClass = NODE_TYPES [ node_type ] node = NodeClass ( workflow = workflow , node_type = node_type , name = name ) for attr in attrs : setattr ( node , attr , attrs [ attr ] ) node . save ( ) if parents : for parent in parents : name = 'ok' if ( ( parent . node_type == 'start' ) or ( parent . node_type == 'join' ) ) : name = 'to' elif ( ( parent . node_type == 'fork' ) or ( parent . node_type == 'decision' ) ) : name = 'start' link = Link ( parent = parent , child = node , name = name ) link . save ( ) if ( ( node_type != 'fork' ) and ( node_type != 'decision' ) and ( node_type != 'join' ) ) : link = Link ( parent = node , child = Kill . objects . get ( name = 'kill' , workflow = workflow ) , name = 'error' ) link . save ( ) return node
create a node of type node_type and associate the listed parents .