summaryrefslogtreecommitdiff
path: root/src/mailman/model
diff options
context:
space:
mode:
authorAbhilash Raj2015-04-20 15:16:15 +0530
committerAbhilash Raj2015-04-20 15:16:15 +0530
commit58ea970fa0f9064ae052d2b9ae1371ef00bd23e6 (patch)
tree4d21000f8ad772377a655ff332288b1c753f5be1 /src/mailman/model
parentec053e7682b14181147d0b7bedb1e5b19a46b56b (diff)
parent3eb81bf5078868b0fc44f991b0b4536a2a3f4b47 (diff)
downloadmailman-58ea970fa0f9064ae052d2b9ae1371ef00bd23e6.tar.gz
mailman-58ea970fa0f9064ae052d2b9ae1371ef00bd23e6.tar.zst
mailman-58ea970fa0f9064ae052d2b9ae1371ef00bd23e6.zip
merge trunk and fix merge conflicts
Diffstat (limited to 'src/mailman/model')
-rw-r--r--src/mailman/model/docs/pending.rst19
-rw-r--r--src/mailman/model/docs/registration.rst18
-rw-r--r--src/mailman/model/pending.py5
3 files changed, 34 insertions, 8 deletions
diff --git a/src/mailman/model/docs/pending.rst b/src/mailman/model/docs/pending.rst
index 4a14edb2a..03eee3772 100644
--- a/src/mailman/model/docs/pending.rst
+++ b/src/mailman/model/docs/pending.rst
@@ -43,10 +43,9 @@ There's exactly one entry in the pendings database now.
>>> pendingdb.count
1
-There's not much you can do with tokens except to *confirm* them, which
-basically means returning the `IPendable` structure (as a dictionary) from the
-database that matches the token. If the token isn't in the database, None is
-returned.
+You can *confirm* the pending, which means returning the `IPendable` structure
+(as a dictionary) from the database that matches the token. If the token
+isn't in the database, None is returned.
>>> pendable = pendingdb.confirm(b'missing')
>>> print(pendable)
@@ -83,6 +82,18 @@ expunge it.
>>> print(pendingdb.confirm(token_1))
None
+You can iterate over all the pendings in the database.
+
+ >>> pendables = list(pendingdb)
+ >>> def sort_key(item):
+ ... token, pendable = item
+ ... return pendable['type']
+ >>> sorted_pendables = sorted(pendables, key=sort_key)
+ >>> for token, pendable in sorted_pendables:
+ ... print(pendable['type'])
+ three
+ two
+
An event can be given a lifetime when it is pended, otherwise it just uses a
default lifetime.
diff --git a/src/mailman/model/docs/registration.rst b/src/mailman/model/docs/registration.rst
index fc7ad6f1a..4b1e13520 100644
--- a/src/mailman/model/docs/registration.rst
+++ b/src/mailman/model/docs/registration.rst
@@ -35,11 +35,13 @@ which represents this work flow.
Anne attempts to join the mailing list.
- >>> token = registrar.register(anne)
+ >>> token, token_owner, member = registrar.register(anne)
Because her email address has not yet been verified, she has not yet become a
member of the mailing list.
+ >>> print(member)
+ None
>>> print(mlist.members.get_member('anne@example.com'))
None
@@ -47,7 +49,10 @@ Once she verifies her email address, she will become a member of the mailing
list. In this case, verifying implies that she also confirms her wish to join
the mailing list.
- >>> registrar.confirm(token)
+ >>> token, token_owner, member = registrar.confirm(token)
+ >>> member
+ <Member: Anne Person <anne@example.com> on ant@example.com
+ as MemberRole.member>
>>> mlist.members.get_member('anne@example.com')
<Member: Anne Person <anne@example.com> on ant@example.com
as MemberRole.member>
@@ -78,13 +83,18 @@ Now when Bart registers as a user for the mailing list, a token will still be
generated, but this is only used by the moderator. At first, Bart is not
subscribed to the mailing list.
- >>> token = registrar.register(bart)
+ >>> token, token_owner, member = registrar.register(bart)
+ >>> print(member)
+ None
>>> print(mlist.members.get_member('bart@example.com'))
None
When the moderator confirms Bart's subscription, he joins the mailing list.
- >>> registrar.confirm(token)
+ >>> token, token_owner, member = registrar.confirm(token)
+ >>> member
+ <Member: Bart Person <bart@example.com> on ant@example.com
+ as MemberRole.member>
>>> mlist.members.get_member('bart@example.com')
<Member: Bart Person <bart@example.com> on ant@example.com
as MemberRole.member>
diff --git a/src/mailman/model/pending.py b/src/mailman/model/pending.py
index bbe95d5f0..04b63f2ca 100644
--- a/src/mailman/model/pending.py
+++ b/src/mailman/model/pending.py
@@ -166,6 +166,11 @@ class Pendings:
store.delete(keyvalue)
store.delete(pending)
+ @dbconnection
+ def __iter__(self, store):
+ for pending in store.query(Pended).all():
+ yield pending.token, self.confirm(pending.token, expunge=False)
+
@property
@dbconnection
def count(self, store):