From 990f3c63814bcfddef2e661248c44e67e945de04 Mon Sep 17 00:00:00 2001
From: Aurélien Bompard
Date: Wed, 25 Mar 2015 18:11:11 +0100
Subject: Add a table to store workflow states
---
src/mailman/config/configure.zcml | 5 +++
.../versions/2bb9b382198_workflow_state_table.py | 28 +++++++++++++++
src/mailman/interfaces/workflowstate.py | 42 ++++++++++++++++++++++
src/mailman/model/workflowstate.py | 41 +++++++++++++++++++++
4 files changed, 116 insertions(+)
create mode 100644 src/mailman/database/alembic/versions/2bb9b382198_workflow_state_table.py
create mode 100644 src/mailman/interfaces/workflowstate.py
create mode 100644 src/mailman/model/workflowstate.py
diff --git a/src/mailman/config/configure.zcml b/src/mailman/config/configure.zcml
index 24061f0f0..6f5876aa8 100644
--- a/src/mailman/config/configure.zcml
+++ b/src/mailman/config/configure.zcml
@@ -117,4 +117,9 @@
factory="mailman.app.templates.TemplateLoader"
/>
+
+
diff --git a/src/mailman/database/alembic/versions/2bb9b382198_workflow_state_table.py b/src/mailman/database/alembic/versions/2bb9b382198_workflow_state_table.py
new file mode 100644
index 000000000..23b3adebb
--- /dev/null
+++ b/src/mailman/database/alembic/versions/2bb9b382198_workflow_state_table.py
@@ -0,0 +1,28 @@
+"""Workflow state table
+
+Revision ID: 2bb9b382198
+Revises: 16c2b25c7b
+Create Date: 2015-03-25 18:09:18.338790
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '2bb9b382198'
+down_revision = '16c2b25c7b'
+
+from alembic import op
+import sqlalchemy as sa
+
+
+def upgrade():
+ op.create_table('workflowstate',
+ sa.Column('name', sa.Unicode(), nullable=False),
+ sa.Column('key', sa.Unicode(), nullable=False),
+ sa.Column('step', sa.Unicode(), nullable=False),
+ sa.Column('data', sa.Unicode(), nullable=True),
+ sa.PrimaryKeyConstraint('name', 'key')
+ )
+
+
+def downgrade():
+ op.drop_table('workflowstate')
diff --git a/src/mailman/interfaces/workflowstate.py b/src/mailman/interfaces/workflowstate.py
new file mode 100644
index 000000000..bb08fef2d
--- /dev/null
+++ b/src/mailman/interfaces/workflowstate.py
@@ -0,0 +1,42 @@
+# Copyright (C) 2007-2015 by the Free Software Foundation, Inc.
+#
+# This file is part of GNU Mailman.
+#
+# GNU Mailman is free software: you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option)
+# any later version.
+#
+# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# GNU Mailman. If not, see .
+
+"""Interface describing the state of a workflow."""
+
+__all__ = [
+ 'IWorkflowState',
+ ]
+
+
+from zope.interface import Interface, Attribute
+
+
+
+class IWorkflowState(Interface):
+ """A basic user."""
+
+ name = Attribute(
+ """The name of the workflow.""")
+
+ key = Attribute(
+ """A unique key identifying the workflow instance.""")
+
+ step = Attribute(
+ """This workflow's next step.""")
+
+ data = Attribute(
+ """Additional data (may be JSON-encodedeJSON .""")
diff --git a/src/mailman/model/workflowstate.py b/src/mailman/model/workflowstate.py
new file mode 100644
index 000000000..5e3301dcf
--- /dev/null
+++ b/src/mailman/model/workflowstate.py
@@ -0,0 +1,41 @@
+# Copyright (C) 2007-2015 by the Free Software Foundation, Inc.
+#
+# This file is part of GNU Mailman.
+#
+# GNU Mailman is free software: you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option)
+# any later version.
+#
+# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# GNU Mailman. If not, see .
+
+"""Model for workflow states."""
+
+__all__ = [
+ 'WorkflowState',
+ ]
+
+
+from mailman.database.model import Model
+from mailman.interfaces.workflowstate import IWorkflowState
+from sqlalchemy import Column, Unicode
+from zope.interface import implementer
+
+
+
+@implementer(IWorkflowState)
+class WorkflowState(Model):
+ """Workflow states."""
+
+ __tablename__ = 'workflowstate'
+
+ name = Column(Unicode, primary_key=True)
+ key = Column(Unicode, primary_key=True)
+ step = Column(Unicode, nullable=False)
+ data = Column(Unicode)
--
cgit v1.2.3-70-g09d2