summaryrefslogtreecommitdiff
path: root/src/mailman/app/workflow.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman/app/workflow.py')
-rw-r--r--src/mailman/app/workflow.py22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/mailman/app/workflow.py b/src/mailman/app/workflow.py
index 92b78c184..e705668f8 100644
--- a/src/mailman/app/workflow.py
+++ b/src/mailman/app/workflow.py
@@ -56,7 +56,7 @@ class Workflow:
self._next.append(step)
def _pop(self):
- name = self._next.popleft()
+ name = self._next.pop()
step = getattr(self, '_step_{}'.format(name))
self._count += 1
if self.debug: # pragma: nocover
@@ -119,20 +119,12 @@ class Workflow:
assert self.token, 'Workflow token must be set'
state_manager = getUtility(IWorkflowStateManager)
data = {attr: getattr(self, attr) for attr in self.SAVE_ATTRIBUTES}
- # Note: only the next step is saved, not the whole stack. This is not
- # an issue in practice, since there's never more than a single step in
- # the queue anyway. If we want to support more than a single step in
- # the queue *and* want to support state saving/restoring, change this
- # method and the restore() method.
+ # Save the workflow stack.
if len(self._next) == 0:
- step = None
- elif len(self._next) == 1:
- step = self._next[0]
+ steps = '[]'
else:
- raise AssertionError(
- "Can't save a workflow state with more than one step "
- "in the queue")
- state_manager.save(self.token, step, json.dumps(data))
+ steps = json.dumps(list(self._next))
+ state_manager.save(self.token, steps, json.dumps(data))
def restore(self):
state_manager = getUtility(IWorkflowStateManager)
@@ -141,8 +133,8 @@ class Workflow:
# The token doesn't exist in the database.
raise LookupError(self.token)
self._next.clear()
- if state.step:
- self._next.append(state.step)
+ if state.steps:
+ self._next.extend(json.loads(state.steps))
data = json.loads(state.data)
for attr in self.SAVE_ATTRIBUTES:
try: