summaryrefslogtreecommitdiff
path: root/src/mailman/interfaces
diff options
context:
space:
mode:
authorBarry Warsaw2016-10-17 09:13:32 -0400
committerBarry Warsaw2016-10-17 09:13:32 -0400
commitd45af03c4f2a560d51631fdfa7c55cd1a98e722c (patch)
tree6cc33aa452d78c38a5d38e83855c5341f0422c2a /src/mailman/interfaces
parent82a913bbf0e8772e7c98d5eb6160fe5b9f7f6f60 (diff)
downloadmailman-d45af03c4f2a560d51631fdfa7c55cd1a98e722c.tar.gz
mailman-d45af03c4f2a560d51631fdfa7c55cd1a98e722c.tar.zst
mailman-d45af03c4f2a560d51631fdfa7c55cd1a98e722c.zip
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.
Diffstat (limited to 'src/mailman/interfaces')
-rw-r--r--src/mailman/interfaces/workflow.py14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/mailman/interfaces/workflow.py b/src/mailman/interfaces/workflow.py
index bf2138959..9846f4683 100644
--- a/src/mailman/interfaces/workflow.py
+++ b/src/mailman/interfaces/workflow.py
@@ -25,8 +25,6 @@ from zope.interface import Attribute, Interface
class IWorkflowState(Interface):
"""The state of a workflow."""
- name = Attribute('The name of the workflow.')
-
token = Attribute('A unique key identifying the workflow instance.')
step = Attribute("This workflow's next step.")
@@ -38,11 +36,9 @@ class IWorkflowState(Interface):
class IWorkflowStateManager(Interface):
"""The workflow states manager."""
- def save(name, token, step, data=None):
+ def save(token, step, data=None):
"""Save the state of a workflow.
- :param name: The name of the workflow.
- :type name: str
:param token: A unique token identifying this workflow instance.
:type token: str
:param step: The next step for this workflow.
@@ -51,11 +47,9 @@ class IWorkflowStateManager(Interface):
:type data: str
"""
- def restore(name, token):
+ def restore(token):
"""Get the saved state for a workflow or None if nothing was saved.
- :param name: The name of the workflow.
- :type name: str
:param token: A unique token identifying this workflow instance.
:type token: str
:return: The saved state associated with this name/token pair, or None
@@ -63,11 +57,9 @@ class IWorkflowStateManager(Interface):
:rtype: ``IWorkflowState``
"""
- def discard(name, token):
+ def discard(token):
"""Throw away the saved state for a workflow.
- :param name: The name of the workflow.
- :type name: str
:param token: A unique token identifying this workflow instance.
:type token: str
"""