summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurélien Bompard2015-12-02 10:30:59 +0100
committerBarry Warsaw2015-12-16 11:04:25 -0500
commit30611aa0d445bc5e19ce37f6b01289f9cc2b7f0b (patch)
tree2bebcd25549b9f8200137f1c49483828d65a88ef
parented9efb350c7629be2b8f1fe509c74e5dca6935f0 (diff)
downloadmailman-30611aa0d445bc5e19ce37f6b01289f9cc2b7f0b.tar.gz
mailman-30611aa0d445bc5e19ce37f6b01289f9cc2b7f0b.tar.zst
mailman-30611aa0d445bc5e19ce37f6b01289f9cc2b7f0b.zip
-rw-r--r--src/mailman/app/bounces.py1
-rw-r--r--src/mailman/app/docs/moderator.rst1
-rw-r--r--src/mailman/app/registrar.py2
-rw-r--r--src/mailman/app/subscriptions.py2
-rw-r--r--src/mailman/app/tests/test_bounces.py4
-rw-r--r--src/mailman/chains/hold.py5
-rw-r--r--src/mailman/interfaces/pending.py2
-rw-r--r--src/mailman/model/docs/pending.rst3
-rw-r--r--src/mailman/model/docs/requests.rst2
-rw-r--r--src/mailman/model/pending.py12
-rw-r--r--src/mailman/model/requests.py2
-rw-r--r--src/mailman/model/tests/test_pending.py2
-rw-r--r--src/mailman/rest/docs/sub-moderation.rst2
13 files changed, 27 insertions, 13 deletions
diff --git a/src/mailman/app/bounces.py b/src/mailman/app/bounces.py
index e6207721c..ef8df15cd 100644
--- a/src/mailman/app/bounces.py
+++ b/src/mailman/app/bounces.py
@@ -176,6 +176,7 @@ class ProbeVERP(_BaseVERPParser):
@implementer(IPendable)
class _ProbePendable(dict):
"""The pendable dictionary for probe messages."""
+ PEND_TYPE = 'probe'
def send_probe(member, msg):
diff --git a/src/mailman/app/docs/moderator.rst b/src/mailman/app/docs/moderator.rst
index 13dba1f37..bf8a8e5df 100644
--- a/src/mailman/app/docs/moderator.rst
+++ b/src/mailman/app/docs/moderator.rst
@@ -168,6 +168,7 @@ however the message metadata indicates that the message has been approved.
_parsemsg : False
approved : True
moderator_approved: True
+ type : data
version : 3
diff --git a/src/mailman/app/registrar.py b/src/mailman/app/registrar.py
index 1b051a7f3..bdc271964 100644
--- a/src/mailman/app/registrar.py
+++ b/src/mailman/app/registrar.py
@@ -43,7 +43,7 @@ log = logging.getLogger('mailman.error')
@implementer(IPendable)
class PendableRegistration(dict):
- PEND_KEY = 'registration'
+ PEND_TYPE = 'registration'
diff --git a/src/mailman/app/subscriptions.py b/src/mailman/app/subscriptions.py
index 0ff7dac6b..19e77e0ef 100644
--- a/src/mailman/app/subscriptions.py
+++ b/src/mailman/app/subscriptions.py
@@ -68,7 +68,7 @@ class WhichSubscriber(Enum):
@implementer(IPendable)
class Pendable(dict):
- pass
+ PEND_TYPE = 'subscription'
diff --git a/src/mailman/app/tests/test_bounces.py b/src/mailman/app/tests/test_bounces.py
index ef77d88a0..5564b964a 100644
--- a/src/mailman/app/tests/test_bounces.py
+++ b/src/mailman/app/tests/test_bounces.py
@@ -207,9 +207,9 @@ Message-ID: <first>
# corresponds to a record in the pending database.
token = send_probe(self._member, self._msg)
pendable = getUtility(IPendings).confirm(token)
- self.assertEqual(len(pendable.items()), 2)
+ self.assertEqual(len(pendable.items()), 3)
self.assertEqual(set(pendable.keys()),
- set(['member_id', 'message_id']))
+ set(['member_id', 'message_id', 'type']))
# member_ids are pended as unicodes.
self.assertEqual(uuid.UUID(hex=pendable['member_id']),
self._member.member_id)
diff --git a/src/mailman/chains/hold.py b/src/mailman/chains/hold.py
index 15219c8ec..3b0c5d24c 100644
--- a/src/mailman/chains/hold.py
+++ b/src/mailman/chains/hold.py
@@ -55,7 +55,7 @@ log = logging.getLogger('mailman.vette')
@implementer(IPendable)
class HeldMessagePendable(dict):
- PEND_KEY = 'held message'
+ PEND_TYPE = 'held message'
@@ -149,8 +149,7 @@ class HoldChain(TerminalChainBase):
request_id = hold_message(mlist, msg, msgdata, None)
# Calculate a confirmation token to send to the author of the
# message.
- pendable = HeldMessagePendable(type=HeldMessagePendable.PEND_KEY,
- id=request_id)
+ pendable = HeldMessagePendable(id=request_id)
token = getUtility(IPendings).add(pendable)
# Get the language to send the response in. If the sender is a
# member, then send it in the member's language, otherwise send it in
diff --git a/src/mailman/interfaces/pending.py b/src/mailman/interfaces/pending.py
index c921123de..d71322e77 100644
--- a/src/mailman/interfaces/pending.py
+++ b/src/mailman/interfaces/pending.py
@@ -37,6 +37,8 @@ from zope.interface import Interface, Attribute
class IPendable(Interface):
"""A pendable object."""
+ PEND_TYPE = Attribute("""The type of this pendable.""")
+
def keys():
"""The keys of the pending event data, all of which are strings."""
diff --git a/src/mailman/model/docs/pending.rst b/src/mailman/model/docs/pending.rst
index 03eee3772..4accf5f3f 100644
--- a/src/mailman/model/docs/pending.rst
+++ b/src/mailman/model/docs/pending.rst
@@ -26,10 +26,9 @@ token that can be used in urls and such.
>>> from mailman.interfaces.pending import IPendable
>>> @implementer(IPendable)
... class SimplePendable(dict):
- ... pass
+ ... PEND_TYPE = 'subscription'
>>> subscription = SimplePendable(
- ... type='subscription',
... address='aperson@example.com',
... display_name='Anne Person',
... language='en',
diff --git a/src/mailman/model/docs/requests.rst b/src/mailman/model/docs/requests.rst
index 1e1eba35a..ad892a18b 100644
--- a/src/mailman/model/docs/requests.rst
+++ b/src/mailman/model/docs/requests.rst
@@ -124,6 +124,7 @@ an additional key which holds the name of the request type.
_request_type: held_message
bar : no
foo : yes
+ type : data
Iterating over requests
@@ -146,6 +147,7 @@ over by type.
_request_type: held_message
bar: no
foo: yes
+ type: data
Deleting requests
diff --git a/src/mailman/model/pending.py b/src/mailman/model/pending.py
index a98c9dfb8..54188c39f 100644
--- a/src/mailman/model/pending.py
+++ b/src/mailman/model/pending.py
@@ -79,7 +79,7 @@ class Pended(Model):
@implementer(IPendable)
class UnpendedPendable(dict):
- pass
+ PEND_TYPE = 'unpended'
@@ -114,6 +114,9 @@ class Pendings:
pending = Pended(
token=token,
expiration_date=now() + lifetime)
+ pendable_type = pendable.pop('type', pendable.PEND_TYPE)
+ pending.key_values.append(
+ PendedKeyValue(key='type', value=pendable_type))
for key, value in pendable.items():
# Both keys and values must be strings.
if isinstance(key, bytes):
@@ -141,7 +144,10 @@ class Pendings:
# Iter on PendedKeyValue entries that are associated with the pending
# object's ID. Watch out for type conversions.
for keyvalue in pending.key_values:
- value = json.loads(keyvalue.value)
+ if keyvalue.key == 'type':
+ value = keyvalue.value
+ else:
+ value = json.loads(keyvalue.value)
if isinstance(value, dict) and '__encoding__' in value:
value = value['value'].encode(value['__encoding__'])
pendable[keyvalue.key] = value
@@ -169,7 +175,7 @@ class Pendings:
pkv_alias_type = aliased(PendedKeyValue)
query = query.join(pkv_alias_type).filter(and_(
pkv_alias_type.key == 'type',
- pkv_alias_type.value == json.dumps(type)
+ pkv_alias_type.value == type
))
for pending in query:
yield pending.token, self.confirm(pending.token, expunge=False)
diff --git a/src/mailman/model/requests.py b/src/mailman/model/requests.py
index e984d0aea..f9cbf69b3 100644
--- a/src/mailman/model/requests.py
+++ b/src/mailman/model/requests.py
@@ -41,6 +41,8 @@ from zope.interface import implementer
class DataPendable(dict):
"""See `IPendable`."""
+ PEND_TYPE = 'data'
+
def update(self, mapping):
# Keys and values must be strings (unicodes, but bytes values are
# accepted for now). Any other types for keys are a programming
diff --git a/src/mailman/model/tests/test_pending.py b/src/mailman/model/tests/test_pending.py
index c97fdc1ce..b84885682 100644
--- a/src/mailman/model/tests/test_pending.py
+++ b/src/mailman/model/tests/test_pending.py
@@ -35,7 +35,7 @@ from zope.interface import implementer
@implementer(IPendable)
class SimplePendable(dict):
- pass
+ PEND_TYPE = 'simple'
diff --git a/src/mailman/rest/docs/sub-moderation.rst b/src/mailman/rest/docs/sub-moderation.rst
index 52b2b89fd..79cee6fb7 100644
--- a/src/mailman/rest/docs/sub-moderation.rst
+++ b/src/mailman/rest/docs/sub-moderation.rst
@@ -51,6 +51,7 @@ The subscription request can be viewed in the REST API.
list_id: ant.example.com
token: ...
token_owner: moderator
+ type: subscription
when: 2005-08-01T07:49:23
http_etag: "..."
start: 0
@@ -71,6 +72,7 @@ You can view an individual membership change request by providing the token
list_id: ant.example.com
token: ...
token_owner: moderator
+ type: subscription
when: 2005-08-01T07:49:23