Commit c8779a10 authored by Barry Warsaw's avatar Barry Warsaw

Implement the REST API for <api>/owners.

parent dfc1cff7
......@@ -35,6 +35,13 @@ Anne's server owner flag is set.
And now we can find her user record.
>>> dump_json('http://localhost:9001/3.0/owners')
entry 0:
created_on: 2005-08-01T07:49:23
display_name: Anne Person
http_etag: "..."
is_server_owner: True
self_link: http://localhost:9001/3.0/users/1
user_id: 1
http_etag: "..."
start: 0
total_size: 1
......@@ -45,6 +52,13 @@ Bart and Cate are also users, but not server owners.
>>> cate = user_manager.create_user('[email protected]', 'Cate Person')
>>> transaction.commit()
>>> dump_json('http://localhost:9001/3.0/owners')
entry 0:
created_on: 2005-08-01T07:49:23
display_name: Anne Person
http_etag: "..."
is_server_owner: True
self_link: http://localhost:9001/3.0/users/1
user_id: 1
http_etag: "..."
start: 0
total_size: 1
......@@ -56,6 +70,20 @@ Anne retires as a server owner, with Bart and Cate taking over.
>>> cate.is_server_owner = True
>>> transaction.commit()
>>> dump_json('http://localhost:9001/3.0/owners')
entry 0:
created_on: 2005-08-01T07:49:23
display_name: Bart Person
http_etag: "..."
is_server_owner: True
self_link: http://localhost:9001/3.0/users/2
user_id: 2
entry 1:
created_on: 2005-08-01T07:49:23
display_name: Cate Person
http_etag: "..."
is_server_owner: True
self_link: http://localhost:9001/3.0/users/3
user_id: 3
http_etag: "..."
start: 0
total_size: 2
......@@ -29,7 +29,6 @@ from mailman.config import config
from mailman.core.constants import system_preferences
from mailman.core.system import system
from mailman.interfaces.listmanager import IListManager
from mailman.interfaces.usermanager import IUserManager
from mailman.model.uid import UID
from mailman.rest.addresses import AllAddresses, AnAddress
from mailman.rest.domains import ADomain, AllDomains
......@@ -40,7 +39,7 @@ from mailman.rest.members import AMember, AllMembers, FindMembers
from mailman.rest.preferences import ReadOnlyPreferences
from mailman.rest.queues import AQueue, AQueueFile, AllQueues
from mailman.rest.templates import TemplateFinder
from mailman.rest.users import AUser, AllUsers
from mailman.rest.users import AUser, AllUsers, ServerOwners
from zope.component import getUtility
......@@ -239,7 +238,8 @@ class TopLevel:
"""/<api>/owners"""
if len(segments) != 0:
return BadRequest(), []
else:
return ServerOwners(), segments
@child()
def templates(self, request, segments):
......
......@@ -464,3 +464,18 @@ class OwnersForDomain(_UserBase):
def _get_collection(self, request):
"""See `CollectionMixin`."""
return list(self._domain.owners)
class ServerOwners(_UserBase):
"""All server owners."""
def on_get(self, request, response):
"""/owners"""
resource = self._make_collection(request)
okay(response, etag(resource))
@paginate
def _get_collection(self, request):
"""See `CollectionMixin`."""
return list(getUtility(IUserManager).server_owners)
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