aboutsummaryrefslogtreecommitdiff
path: root/src/mailman_pgp
diff options
context:
space:
mode:
authorJ08nY2017-08-06 02:51:44 +0200
committerJ08nY2017-08-06 02:51:44 +0200
commit009a60e504f9441aace4a490bfe811d0471e2dfd (patch)
tree865f9ccf63f2118a0262dacab508e99a4f316894 /src/mailman_pgp
parentb56debf2d3db0732e6fa4a3d22ecaaae78fc5b65 (diff)
downloadmailman-pgp-009a60e504f9441aace4a490bfe811d0471e2dfd.tar.gz
mailman-pgp-009a60e504f9441aace4a490bfe811d0471e2dfd.tar.zst
mailman-pgp-009a60e504f9441aace4a490bfe811d0471e2dfd.zip
Diffstat (limited to 'src/mailman_pgp')
-rw-r--r--src/mailman_pgp/workflows/base.py23
-rw-r--r--src/mailman_pgp/workflows/key_change.py20
-rw-r--r--src/mailman_pgp/workflows/subscription.py8
-rw-r--r--src/mailman_pgp/workflows/tests/test_base.py2
4 files changed, 28 insertions, 25 deletions
diff --git a/src/mailman_pgp/workflows/base.py b/src/mailman_pgp/workflows/base.py
index 42515e2..82dd291 100644
--- a/src/mailman_pgp/workflows/base.py
+++ b/src/mailman_pgp/workflows/base.py
@@ -20,13 +20,28 @@ from public import public
from mailman_pgp.database import transaction
from mailman_pgp.model.address import PGPAddress
+from mailman_pgp.model.list import PGPMailingList
@public
class PGPMixin:
+ def __init__(self, mlist, pgp_address=None):
+ self.mlist = mlist
+ self.pgp_list = PGPMailingList.for_list(mlist)
+ self.pgp_address = pgp_address
+
+ @property
+ def address_key(self):
+ return self.pgp_address.email
+
+ @address_key.setter
+ def address_key(self, value):
+ self.pgp_address = PGPAddress.for_email(value)
+ self.member = self.mlist.regular_members.get_member(value)
+
def _step_pgp_prepare(self):
- pgp_address = PGPAddress.for_address(self.address)
- if pgp_address is None:
+ self.pgp_address = PGPAddress.for_address(self.address)
+ if self.pgp_address is None:
with transaction() as t:
- pgp_address = PGPAddress(self.address)
- t.add(pgp_address)
+ self.pgp_address = PGPAddress(self.address)
+ t.add(self.pgp_address)
diff --git a/src/mailman_pgp/workflows/key_change.py b/src/mailman_pgp/workflows/key_change.py
index fce7b71..b2fac65 100644
--- a/src/mailman_pgp/workflows/key_change.py
+++ b/src/mailman_pgp/workflows/key_change.py
@@ -28,10 +28,9 @@ from zope.interface import implementer
from mailman_pgp.config import config
from mailman_pgp.database import transaction
-from mailman_pgp.model.address import PGPAddress
-from mailman_pgp.model.list import PGPMailingList
from mailman_pgp.pgp.wrapper import PGPWrapper
from mailman_pgp.utils.email import copy_headers
+from mailman_pgp.workflows.base import PGPMixin
from mailman_pgp.workflows.mod_approval import (
ModeratorKeyChangeApprovalMixin)
@@ -48,29 +47,18 @@ Token: {}
"""
-class KeyChangeBase(Workflow):
+class KeyChangeBase(Workflow, PGPMixin):
save_attributes = (
'address_key',
'pubkey_key'
)
def __init__(self, mlist, pgp_address=None, pubkey=None):
- super().__init__()
- self.mlist = mlist
- self.pgp_list = PGPMailingList.for_list(mlist)
- self.pgp_address = pgp_address
+ Workflow.__init__(self)
+ PGPMixin.__init__(self, mlist, pgp_address)
self.pubkey = pubkey
@property
- def address_key(self):
- return self.pgp_address.email
-
- @address_key.setter
- def address_key(self, value):
- self.pgp_address = PGPAddress.for_email(value)
- self.member = self.mlist.regular_members.get_member(value)
-
- @property
def pubkey_key(self):
return str(self.pubkey)
diff --git a/src/mailman_pgp/workflows/subscription.py b/src/mailman_pgp/workflows/subscription.py
index d5803c2..bba33cf 100644
--- a/src/mailman_pgp/workflows/subscription.py
+++ b/src/mailman_pgp/workflows/subscription.py
@@ -58,7 +58,7 @@ class OpenSubscriptionPolicy(SubscriptionBase, VerificationMixin,
VerificationMixin.__init__(self, pre_verified=pre_verified)
SetPubkeyMixin.__init__(self, pubkey=pubkey)
ConfirmPubkeyMixin.__init__(self, pre_confirmed=pubkey_pre_confirmed)
- PGPMixin.__init__(self)
+ PGPMixin.__init__(self, mlist)
def _step_prepare(self):
self.push('do_subscription')
@@ -99,7 +99,7 @@ class ConfirmSubscriptionPolicy(SubscriptionBase, VerificationMixin,
ConfirmationMixin.__init__(self, pre_confirmed=pre_confirmed)
SetPubkeyMixin.__init__(self, pubkey=pubkey)
ConfirmPubkeyMixin.__init__(self, pre_confirmed=pubkey_pre_confirmed)
- PGPMixin.__init__(self)
+ PGPMixin.__init__(self, mlist)
def _step_prepare(self):
self.push('do_subscription')
@@ -141,7 +141,7 @@ class ModerationSubscriptionPolicy(SubscriptionBase, VerificationMixin,
ModeratorSubApprovalMixin.__init__(self, pre_approved=pre_approved)
SetPubkeyMixin.__init__(self, pubkey=pubkey)
ConfirmPubkeyMixin.__init__(self, pre_confirmed=pubkey_pre_confirmed)
- PGPMixin.__init__(self)
+ PGPMixin.__init__(self, mlist)
def _step_prepare(self):
self.push('do_subscription')
@@ -187,7 +187,7 @@ class ConfirmModerationSubscriptionPolicy(SubscriptionBase, VerificationMixin,
ModeratorSubApprovalMixin.__init__(self, pre_approved=pre_approved)
SetPubkeyMixin.__init__(self, pubkey=pubkey)
ConfirmPubkeyMixin.__init__(self, pre_confirmed=pubkey_pre_confirmed)
- PGPMixin.__init__(self)
+ PGPMixin.__init__(self, mlist)
def _step_prepare(self):
self.push('do_subscription')
diff --git a/src/mailman_pgp/workflows/tests/test_base.py b/src/mailman_pgp/workflows/tests/test_base.py
index 440068c..febd8b9 100644
--- a/src/mailman_pgp/workflows/tests/test_base.py
+++ b/src/mailman_pgp/workflows/tests/test_base.py
@@ -79,7 +79,7 @@ class PGPTestWorkflow(SubscriptionBase, PGPMixin, SetPubkeyMixin,
SubscriptionBase.__init__(self, mlist, subscriber)
SetPubkeyMixin.__init__(self, pubkey=pubkey)
ConfirmPubkeyMixin.__init__(self, pre_confirmed=pubkey_pre_confirmed)
- PGPMixin.__init__(self)
+ PGPMixin.__init__(self, mlist)
def _step_prepare(self):
self.push('do_subscription')