Commit f759cae3 authored by Barry Warsaw's avatar Barry Warsaw

Show test for MemberRole.member.

parent 16bf4d15
================
List memberships
================
......@@ -55,7 +56,7 @@ When we create a mailing list, it starts out with no members...
Administrators
--------------
==============
A mailing list's administrators are defined as union of the list's owners and
the list's moderators. We can add new owners or moderators to this list by
......@@ -129,7 +130,7 @@ Now, both Anne and Ben are list administrators.
Members
-------
=======
Similarly, list members are born of users being given the proper role. It's
more interesting here because these roles should have a preference which can
......@@ -178,7 +179,7 @@ It's easy to make the list administrators members of the mailing list too.
Finding members
---------------
===============
You can find the IMember object that is a member of a roster for a given text
email address by using an IRoster's .get_member() method.
......@@ -205,7 +206,7 @@ is returned.
All subscribers
---------------
===============
There is also a roster containing all the subscribers of a mailing list,
regardless of their role.
......@@ -222,7 +223,7 @@ regardless of their role.
Double subscriptions
--------------------
====================
It is an error to subscribe someone to a list with the same role twice.
......
......@@ -36,6 +36,13 @@
factory="mailman.rest.urls.MailingListURLMapper"
/>
<adapter
for="mailman.interfaces.member.IMember
lazr.restful.simple.Request"
provides="zope.traversing.browser.interfaces.IAbsoluteURL"
factory="mailman.rest.urls.MemberURLMapper"
/>
<adapter
for="zope.publisher.interfaces.NotFound
lazr.restful.simple.Request"
......
......@@ -15,11 +15,38 @@ There are no mailing lists and no members yet.
We create a mailing list, which starts out with no members.
>>> create_list('[email protected]')
<mailing list "[email protected]" at ...>
>>> mlist_one = create_list('[email protected]')
>>> transaction.commit()
>>> dump_json('http://localhost:8001/3.0/members')
resource_type_link: http://localhost:8001/3.0/#members
start: None
total_size: 0
Subscribers
===========
After Anne subscribes to the mailing list, her subscription is available via
the REST interface.
>>> from mailman.interfaces.member import MemberRole
>>> from mailman.interfaces.usermanager import IUserManager
>>> from zope.component import getUtility
>>> user_manager = getUtility(IUserManager)
>>> anne = user_manager.create_user('[email protected]', 'Anne Person')
>>> anne_address = list(anne.addresses)[0]
>>> anne_address.subscribe(mlist_one, MemberRole.member)
<Member: Anne Person <[email protected]>
on [email protected] as MemberRole.member>
>>> transaction.commit()
>>> dump_json('http://localhost:8001/3.0/members')
entry 0:
http_etag: "a0213c9ff485ef3d24a6e2cc8ee68ed147f05398"
resource_type_link: http://localhost:8001/3.0/#member
self_link: http://localhost:8001/3.0/members/[email protected]/member/[email protected]
resource_type_link: http://localhost:8001/3.0/#members
start: 0
total_size: 1
......@@ -117,3 +117,17 @@ class MailingListURLMapper(TopLevelURLMapper):
format_string = (
'{0.schema}://{0.hostname}:{0.port}/{0.version}/'
'lists/{0.context.fqdn_listname}')
class MemberURLMapper(TopLevelURLMapper):
"""Mapper of `IMember` to `IAbsoluteURL`."""
def __init__(self, context, request):
super(MemberURLMapper, self).__init__(context, request)
# Use a shorted version of the MemberRole string.
enum, dot, self.role = str(self.context.role).partition('.')
format_string = (
'{0.schema}://{0.hostname}:{0.port}/{0.version}/'
'members/{0.context.mailing_list}/'
'{0.role}/{0.context.address.address}')
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