------------------------------------------------------------
revno: 12
committer: Barry Warsaw <[email protected]>
branch nick: trunk
timestamp: Sun 2010-12-26 16:11:54 -0500
message:
.get_member() for a mailing list
.unsubscribe() on a mailing list
.unsubscribe() on a member.
modified:
mailman/client/_client.py
mailman/client/docs/using.txt
--
lp:mailman.client
https://code.launchpad.net/~mailman-coders/mailman.client/trunk
Your team Mailman Coders is subscribed to branch lp:mailman.client.
To unsubscribe from this branch go to
https://code.launchpad.net/~mailman-coders/mailman.client/trunk/+edit-subscription
=== modified file 'mailman/client/_client.py'
--- mailman/client/_client.py 2010-12-26 21:00:02 +0000
+++ mailman/client/_client.py 2010-12-26 21:11:54 +0000
@@ -282,6 +282,16 @@
for entry in sorted(content['entries'],
key=itemgetter('address'))]
+ def get_member(self, address):
+ """Get a membership.
+
+ :param address: The email address of the member for this list.
+ :return: A member proxy object.
+ """
+ response, content = self._connection.call(
+ 'lists/{0}/member/{1}'.format(self.fqdn_listname, address))
+ return _Member(self._connection, content['self_link'])
+
def subscribe(self, address, real_name=None):
"""Subscribe an email address to a mailing list.
@@ -289,6 +299,7 @@
:type address: str
:param real_name: The real name of the new member.
:type real_name: str
+ :return: A member proxy object.
"""
data = dict(
fqdn_listname=self.fqdn_listname,
@@ -298,6 +309,15 @@
response, content = self._connection.call('members', data)
return _Member(self._connection, response['location'])
+ def unsubscribe(self, address):
+ """Unsubscribe an email address from a mailing list.
+
+ :param address: The address to unsubscribe.
+ """
+ self._connection.call(
+ 'lists/{0}/member/{1}'.format(self.fqdn_listname, address),
+ method='DELETE')
+
class _Member:
@@ -324,3 +344,12 @@
def address(self):
self._get_info()
return self._info['address']
+
+ def unsubscribe(self):
+ """Unsubscribe the member from a mailing list.
+
+ :param address: The address to unsubscribe.
+ """
+ self._connection.call(
+ 'lists/{0}/member/{1}'.format(self.fqdn_listname, self.address),
+ method='DELETE')
=== modified file 'mailman/client/docs/using.txt'
--- mailman/client/docs/using.txt 2010-12-26 21:00:02 +0000
+++ mailman/client/docs/using.txt 2010-12-26 21:11:54 +0000
@@ -164,3 +164,27 @@
... print member
<Member "[email protected]" on "[email protected]">
<Member "[email protected]" on "[email protected]">
+
+We can get a single membership too.
+
+ >>> cris = test_two.get_member('[email protected]')
+ >>> cris
+ <Member "[email protected]" on "[email protected]">
+
+After a while, Anna decides to unsubscribe from the Test One mailing list,
+though she keeps her Test Two membership active.
+
+ >>> test_one.unsubscribe('[email protected]')
+ >>> for member in client.members:
+ ... print member
+ <Member "[email protected]" on "[email protected]">
+ <Member "[email protected]" on "[email protected]">
+ <Member "[email protected]" on "[email protected]">
+
+A little later, Cris decides to unsubscribe from the Test Two mailing list.
+
+ >>> cris.unsubscribe()
+ >>> for member in client.members:
+ ... print member
+ <Member "[email protected]" on "[email protected]">
+ <Member "[email protected]" on "[email protected]">
_______________________________________________
Mailman-coders mailing list
[email protected]
http://mail.python.org/mailman/listinfo/mailman-coders