Commit ef30372e authored by Florian Fuchs's avatar Florian Fuchs

added nonmember property to list objects.

added add_address method to user objects.
parent 84e1e63c
......@@ -24,12 +24,11 @@ from setuptools import setup, find_packages
require_python(0x20600f0)
__version__ = get_version('src/mailmanclient/__init__.py')
setup(
name='mailmanclient',
version=__version__,
version='1.0.0a1',
packages=find_packages('src'),
package_dir = {'': 'src'},
include_package_data=True,
......
......@@ -381,6 +381,20 @@ class _List:
for entry in sorted(content['entries'],
key=itemgetter('address'))]
@property
def nonmembers(self):
url = 'members/find'
data = {
'role': 'nonmember',
'list_id': self.list_id
}
response, content = self._connection.call(url, data)
if 'entries' not in content:
return []
return [_Member(self._connection, entry['self_link'])
for entry in sorted(content['entries'],
key=itemgetter('address'))]
def get_member_page(self, count=50, page=1):
url = 'lists/{0}/roster/member'.format(self.fqdn_listname)
return _Page(self._connection, url, _Member, count, page)
......@@ -690,6 +704,12 @@ class _User:
self._preferences = _Preferences(self._connection, path)
return self._preferences
def add_address(self, email):
# Adds another email adress to the user record and returns an
# _Address object.
url = '{0}/addresses'.format(self._url)
self._connection.call(url, {'email': email})
def save(self):
data = {'display_name': self.display_name}
if self._cleartext_password is not None:
......
......@@ -302,6 +302,7 @@ If you use an address which is not a member of test_two `ValueError` is raised:
After a while, Anna decides to unsubscribe from the Test One mailing list,
though she keeps her Test Two membership active.
>>> time.sleep(2)
>>> test_one.unsubscribe('anna@example.com')
>>> for member in client.members:
... print member
......@@ -336,7 +337,7 @@ Users are people with one or more list memberhips. To get a list of all users, a
<User "..." (...)>
<User "..." (...)>
The users can also be paginated:
The list of users can also be paginated:
>>> page = client.get_user_page(count=2, page=1)
>>> page.nr
......@@ -381,6 +382,21 @@ Every user has a list of one or more addresses.
cris@example.com
Cris
...
Multiple addresses can be assigned to a user record:
>>> cris.add_address('cris.person@example.org')
>>> print client.get_address('cris.person@example.org')
cris.person@example.org
>>> for address in cris.addresses:
... print address
cris.person@example.org
cris@example.com
Addresses
=========
Addresses can be accessed directly:
......
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