Skip to content

Commit 1b1da1d

Browse files
authored
Merge pull request #317 from sartography/bugfix/non-bpmn-tutorial
Bugfix/non bpmn tutorial
2 parents 7388658 + e82345d commit 1b1da1d

File tree

9 files changed

+68
-177
lines changed

9 files changed

+68
-177
lines changed

SpiffWorkflow/serializer/dict.py

Lines changed: 43 additions & 135 deletions
Large diffs are not rendered by default.

SpiffWorkflow/specs/MultiInstance.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ def __init__(self, wf_spec, name, times, **kwargs):
5050
raise ValueError('times argument is required')
5151
TaskSpec.__init__(self, wf_spec, name, **kwargs)
5252
self.times = times
53-
self.prevtaskclass = None
5453

5554
def _find_my_task(self, task):
5655
for thetask in task.workflow.task_tree:

SpiffWorkflow/specs/WorkflowSpec.py

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ def _add_notify(self, task_spec):
4545
if task_spec.name in self.task_specs:
4646
raise KeyError('Duplicate task spec name: ' + task_spec.name)
4747
self.task_specs[task_spec.name] = task_spec
48-
task_spec.id = self.name + '_' + str(len(self.task_specs))
48+
# Why does this attribute even exist???
49+
task_spec.id = str(len(self.task_specs))
4950

5051
def get_task_spec_from_name(self, name):
5152
"""
@@ -58,22 +59,6 @@ def get_task_spec_from_name(self, name):
5859
"""
5960
return self.task_specs.get(name)
6061

61-
def get_task_spec_from_id(self, id):
62-
"""
63-
Returns the task with the given name.
64-
65-
:type name: str
66-
:param name: The name of the task spec.
67-
:rtype: TaskSpec
68-
:returns: The task spec with the given name.
69-
"""
70-
ret_spec = None
71-
for x in self.task_specs:
72-
if self.task_specs[x].id == id:
73-
ret_spec = self.task_specs[x]
74-
return ret_spec
75-
76-
7762
def validate(self):
7863
"""Checks integrity of workflow and reports any problems with it.
7964

SpiffWorkflow/specs/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,8 @@ def serialize(self, serializer, **kwargs):
413413
'class': class_name,
414414
'name':self.name,
415415
'description':self.description,
416-
'inputs':[x.id for x in self.inputs],
417-
'outputs':[x.id for x in self.outputs],
416+
'inputs':[x.name for x in self.inputs],
417+
'outputs':[x.name for x in self.outputs],
418418
'manual':self.manual,
419419
'internal':self.internal,
420420
'data':self.data,

doc/non-bpmn/custom-tasks/start.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
import json
2-
from SpiffWorkflow import Workflow
3-
from SpiffWorkflow.specs import WorkflowSpec
1+
from SpiffWorkflow.workflow import Workflow
2+
from SpiffWorkflow.specs.WorkflowSpec import WorkflowSpec
43
from serializer import NuclearSerializer
54

65
# Load from JSON
76
with open('nuclear.json') as fp:
87
workflow_json = fp.read()
9-
serializer = NuclearSerializer()
10-
spec = WorkflowSpec.deserialize(serializer, workflow_json)
8+
nuclear_serializer = NuclearSerializer()
9+
spec = WorkflowSpec.deserialize(nuclear_serializer, workflow_json)
1110

1211
# Create the workflow.
1312
workflow = Workflow(spec)
1413

1514
# Execute until all tasks are done or require manual intervention.
1615
# For the sake of this tutorial, we ignore the "manual" flag on the
1716
# tasks. In practice, you probably don't want to do that.
18-
workflow.complete_all(halt_on_manual=False)
17+
workflow.run_all(halt_on_manual=False)

doc/non-bpmn/custom-tasks/strike.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from SpiffWorkflow.specs import Simple
1+
from SpiffWorkflow.specs.Simple import Simple
22

33
class NuclearStrike(Simple):
44
def _on_complete_hook(self, my_task):

doc/non-bpmn/tutorial/nuclear.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22
"task_specs": {
33
"Start": {
44
"class": "SpiffWorkflow.specs.StartTask.StartTask",
5-
"id" : 1,
5+
"id" : 1,
66
"manual": false,
77
"outputs": [
8-
2
8+
"general"
99
]
1010
},
1111
"general": {
1212
"class": "SpiffWorkflow.specs.ExclusiveChoice.ExclusiveChoice",
1313
"name": "general",
14-
"id" : 2,
14+
"id" : 2,
1515
"manual": true,
1616
"inputs": [
17-
1
17+
"Start"
1818
],
1919
"outputs": [
20-
5,
21-
3
20+
"workflow_aborted",
21+
"president"
2222
],
2323
"choice": null,
2424
"default_task_spec": "workflow_aborted",
@@ -44,14 +44,14 @@
4444
"president": {
4545
"class": "SpiffWorkflow.specs.ExclusiveChoice.ExclusiveChoice",
4646
"name": "president",
47-
"id" : 3,
47+
"id" : 3,
4848
"manual": true,
4949
"inputs": [
50-
2
50+
"general"
5151
],
5252
"outputs": [
53-
5,
54-
4
53+
"workflow_aborted",
54+
"nuclear_strike"
5555
],
5656
"choice": null,
5757
"default_task_spec": "workflow_aborted",
@@ -75,20 +75,20 @@
7575
]
7676
},
7777
"nuclear_strike": {
78-
"id" : 4,
78+
"id" : 4,
7979
"class": "SpiffWorkflow.specs.Simple.Simple",
8080
"name": "nuclear_strike",
8181
"inputs": [
82-
3
82+
"president"
8383
]
8484
},
8585
"workflow_aborted": {
8686
"id" : 5,
8787
"class": "SpiffWorkflow.specs.Cancel.Cancel",
8888
"name": "workflow_aborted",
8989
"inputs": [
90-
2,
91-
3
90+
"general",
91+
"president"
9292
]
9393
}
9494
},

doc/non-bpmn/tutorial/start.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import json
21
from SpiffWorkflow.workflow import Workflow
32
from SpiffWorkflow.specs.WorkflowSpec import WorkflowSpec
43
from SpiffWorkflow.serializer.json import JSONSerializer

tests/SpiffWorkflow/core/docTest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import sys
44
import unittest
55
import os
6+
67
dirname = os.path.abspath(os.path.dirname(__file__))
78
sys.path.insert(0, os.path.join(dirname, '..', '..', '..'))
89
doc_dir = os.path.join(dirname, '..', '..', '..', 'doc')

0 commit comments

Comments
 (0)