Commit dcdd21c3 authored by Florian Fuchs's avatar Florian Fuchs

worked in API change in MM3 beta2 (membership/list_id)

parent 96527099
......@@ -25,6 +25,7 @@ __all__ = [
]
import re
import json
from base64 import b64encode
......@@ -45,7 +46,7 @@ def _member_key(member_dict):
: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 @@ class _List:
@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 @@ class _List:
: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 @@ class _Member:
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 @@ class _Member:
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):
......
......@@ -185,36 +185,36 @@ New members can be easily added; users are automatically registered.
>>> test_two = client.get_list('test-two@example.com')
>>> test_one.subscribe('anna@example.com', 'Anna')
<Member "anna@example.com" on "test-one@example.com">
<Member "anna@example.com" on "test-one.example.com">
>>> test_one.subscribe('bill@example.com', 'Bill')
<Member "bill@example.com" on "test-one@example.com">
<Member "bill@example.com" on "test-one.example.com">
>>> test_two.subscribe('anna@example.com')
<Member "anna@example.com" on "test-two@example.com">
<Member "anna@example.com" on "test-two.example.com">
>>> test_two.subscribe('cris@example.com', 'Cris')
<Member "cris@example.com" on "test-two@example.com">
<Member "cris@example.com" 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 "anna@example.com" on "test-one@example.com">
<Member "bill@example.com" on "test-one@example.com">
<Member "anna@example.com" on "test-two@example.com">
<Member "cris@example.com" on "test-two@example.com">
<Member "anna@example.com" on "test-one.example.com">
<Member "bill@example.com" on "test-one.example.com">
<Member "anna@example.com" on "test-two.example.com">
<Member "cris@example.com" 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 "anna@example.com" on "test-one@example.com">
<Member "bill@example.com" on "test-one@example.com">
<Member "anna@example.com" on "test-one.example.com">
<Member "bill@example.com" on "test-one.example.com">
We can get a single membership too.
>>> cris = test_two.get_member('cris@example.com')
>>> cris
<Member "cris@example.com" on "test-two@example.com">
<Member "cris@example.com" on "test-two.example.com">
>>> print cris.role
member
>>> print cris.self_link
......@@ -235,17 +235,17 @@ though she keeps her Test Two membership active.
>>> test_one.unsubscribe('anna@example.com')
>>> for member in client.members:
... print member
<Member "bill@example.com" on "test-one@example.com">
<Member "anna@example.com" on "test-two@example.com">
<Member "cris@example.com" on "test-two@example.com">
<Member "bill@example.com" on "test-one.example.com">
<Member "anna@example.com" on "test-two.example.com">
<Member "cris@example.com" 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 "bill@example.com" on "test-one@example.com">
<Member "anna@example.com" on "test-two@example.com">
<Member "bill@example.com" on "test-one.example.com">
<Member "anna@example.com" on "test-two.example.com">
If you try to unsubscribe an address which is not a member address `ValueError` is raised:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment