------------------------------------------------------------
revno: 31
committer: Florian Fuchs <[email protected]>
branch nick: mailman.client
timestamp: Fri 2012-09-21 21:29:12 +0200
message:
worked in API change in MM3 beta2 (membership/list_id)
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 2012-07-17 17:56:36 +0000
+++ mailman/client/_client.py 2012-09-21 19:29:12 +0000
@@ -25,6 +25,7 @@
]
+import re
import json
from base64 import b64encode
@@ -45,7 +46,7 @@
:param member_dict: The JSON dictionary for a member.
:return: 2-tuple of (fqdn_listname, address)
"""
- return (member_dict['fqdn_listname'], member_dict['address'])
+ return (member_dict['list_id'], member_dict['address'])
class MailmanConnectionError(Exception):
@@ -329,8 +330,8 @@
@property
def members(self):
- data = dict(fqdn_listname=self.fqdn_listname)
- response, content = self._connection.call('members/find', data)
+ url = 'lists/{0}/roster/member'.format(self.fqdn_listname)
+ response, content = self._connection.call(url)
if 'entries' not in content:
return []
return [_Member(self._connection, entry['self_link'])
@@ -422,7 +423,7 @@
:return: A member proxy object.
"""
data = dict(
- fqdn_listname=self.fqdn_listname,
+ list_id=re.sub(r'@', '.', self.fqdn_listname),
subscriber=address,
display_name=display_name,
)
@@ -459,7 +460,7 @@
def __repr__(self):
return '<Member "{0}" on "{1}">'.format(
- self.address, self.fqdn_listname)
+ self.address, self.list_id)
def _get_info(self):
if self._info is None:
@@ -467,9 +468,9 @@
self._info = content
@property
- def fqdn_listname(self):
+ def list_id(self):
self._get_info()
- return self._info['fqdn_listname']
+ return self._info['list_id']
@property
def address(self):
=== modified file 'mailman/client/docs/using.txt'
--- mailman/client/docs/using.txt 2012-03-23 23:24:28 +0000
+++ mailman/client/docs/using.txt 2012-09-21 19:29:12 +0000
@@ -185,36 +185,36 @@
>>> test_two = client.get_list('[email protected]')
>>> test_one.subscribe('[email protected]', 'Anna')
- <Member "[email protected]" on "[email protected]">
+ <Member "[email protected]" on "test-one.example.com">
>>> test_one.subscribe('[email protected]', 'Bill')
- <Member "[email protected]" on "[email protected]">
+ <Member "[email protected]" on "test-one.example.com">
>>> test_two.subscribe('[email protected]')
- <Member "[email protected]" on "[email protected]">
+ <Member "[email protected]" on "test-two.example.com">
>>> test_two.subscribe('[email protected]', 'Cris')
- <Member "[email protected]" on "[email protected]">
+ <Member "[email protected]" on "test-two.example.com">
We can retrieve all known memberships. These are sorted first by mailing list
name, then by email address.
>>> 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]">
- <Member "[email protected]" on "[email protected]">
+ <Member "[email protected]" on "test-one.example.com">
+ <Member "[email protected]" on "test-one.example.com">
+ <Member "[email protected]" on "test-two.example.com">
+ <Member "[email protected]" on "test-two.example.com">
We can also view the memberships for a single mailing list.
>>> for member in test_one.members:
... print member
- <Member "[email protected]" on "[email protected]">
- <Member "[email protected]" on "[email protected]">
+ <Member "[email protected]" on "test-one.example.com">
+ <Member "[email protected]" on "test-one.example.com">
We can get a single membership too.
>>> cris = test_two.get_member('[email protected]')
>>> cris
- <Member "[email protected]" on "[email protected]">
+ <Member "[email protected]" on "test-two.example.com">
>>> print cris.role
member
>>> print cris.self_link
@@ -235,17 +235,17 @@
>>> 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]">
+ <Member "[email protected]" on "test-one.example.com">
+ <Member "[email protected]" on "test-two.example.com">
+ <Member "[email protected]" on "test-two.example.com">
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]">
+ <Member "[email protected]" on "test-one.example.com">
+ <Member "[email protected]" on "test-two.example.com">
If you try to unsubscribe an address which is not a member address `ValueError` is raised:
_______________________________________________
Mailman-coders mailing list
[email protected]
http://mail.python.org/mailman/listinfo/mailman-coders