From d45af03c4f2a560d51631fdfa7c55cd1a98e722c Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Mon, 17 Oct 2016 09:13:32 -0400 Subject: Simplify the implementation. This merges the SubscriptionManager and UnsubscriptionManager into a single SubscriptionManager implementation that handles both register() and unregister(). This allows us to use direct class-based adaptation instead of the more clunky getAdapter() API. We can also eliminate the funky _get_workflow() implementation detail. This has a couple of side-effects. .confirm() must lookup the token in the pendings database and pull out the pending type, dispatching to the proper class depending on the type, or raising a LookupError if the token is None or there is no pendable associated with the given token. This feels like an acceptable trade-off. However, this *also* means that IWorkflowStateManager must lose its 'name' argument in its methods. That's because we won't actually know the name until its too late. Honestly, the name wasn't providing much value anyway (it was always the subclass's name), so losing that seems fine too. The complication here is that the name was a primary key in the 'workflowstate' table, so we need to add its removal in the database migration. --- src/mailman/app/workflow.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/mailman/app/workflow.py') diff --git a/src/mailman/app/workflow.py b/src/mailman/app/workflow.py index eec8a14a8..762b0fd91 100644 --- a/src/mailman/app/workflow.py +++ b/src/mailman/app/workflow.py @@ -132,15 +132,11 @@ class Workflow: raise AssertionError( "Can't save a workflow state with more than one step " "in the queue") - state_manager.save( - self.__class__.__name__, - self.token, - step, - json.dumps(data)) + state_manager.save(self.token, step, json.dumps(data)) def restore(self): state_manager = getUtility(IWorkflowStateManager) - state = state_manager.restore(self.__class__.__name__, self.token) + state = state_manager.restore(self.token) if state is None: # The token doesn't exist in the database. raise LookupError(self.token) -- cgit v1.2.3-70-g09d2