1# Copyright (C) 2015-2020 by the Free Software Foundation, Inc. 2# 3# This file is part of GNU Mailman. 4# 5# GNU Mailman is free software: you can redistribute it and/or modify it under 6# the terms of the GNU General Public License as published by the Free 7# Software Foundation, either version 3 of the License, or (at your option) 8# any later version. 9# 10# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT 11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13# more details. 14# 15# You should have received a copy of the GNU General Public License along with 16# GNU Mailman. If not, see <https://www.gnu.org/licenses/>. 17 18"""Interfaces describing the state of a workflow.""" 19 20from public import public 21from zope.interface import Attribute, Interface 22 23 24@public 25class IWorkflowState(Interface): 26 """The state of a workflow.""" 27 28 token = Attribute('A unique key identifying the workflow instance.') 29 30 step = Attribute("This workflow's next step.") 31 32 data = Attribute('Additional data (may be JSON-encoded).') 33 34 35@public 36class IWorkflowStateManager(Interface): 37 """The workflow states manager.""" 38 39 def save(token, step, data=None): 40 """Save the state of a workflow. 41 42 :param token: A unique token identifying this workflow instance. 43 :type token: str 44 :param step: The next step for this workflow. 45 :type step: str 46 :param data: Additional data (workflow-specific). 47 :type data: str 48 """ 49 50 def restore(token): 51 """Get the saved state for a workflow or None if nothing was saved. 52 53 :param token: A unique token identifying this workflow instance. 54 :type token: str 55 :return: The saved state associated with this name/token pair, or None 56 if the pair isn't in the database. 57 :rtype: ``IWorkflowState`` 58 """ 59 60 def discard(token): 61 """Throw away the saved state for a workflow. 62 63 :param token: A unique token identifying this workflow instance. 64 :type token: str 65 """ 66 67 count = Attribute('The number of saved workflows in the database.') 68