summaryrefslogtreecommitdiff
path: root/src/mailman/rest
diff options
context:
space:
mode:
authorBarry Warsaw2009-07-25 00:23:01 -0400
committerBarry Warsaw2009-07-25 00:23:01 -0400
commit9c5c394a0912b56dd0fa1cabe07833aca24b92ef (patch)
tree05a626a418ba364d64c2da54f0f91b6bf3001e25 /src/mailman/rest
parent95163b905be9c912f640b07353451013bd6020a7 (diff)
downloadmailman-9c5c394a0912b56dd0fa1cabe07833aca24b92ef.tar.gz
mailman-9c5c394a0912b56dd0fa1cabe07833aca24b92ef.tar.zst
mailman-9c5c394a0912b56dd0fa1cabe07833aca24b92ef.zip
* Expose IMailingLists in the API.
* Better titles in the IMailingList interface. * Expose the real_name attribute. * Refactor URL mappers.
Diffstat (limited to 'src/mailman/rest')
-rw-r--r--src/mailman/rest/configure.zcml7
-rw-r--r--src/mailman/rest/docs/lists.txt20
-rw-r--r--src/mailman/rest/urls.py32
3 files changed, 51 insertions, 8 deletions
diff --git a/src/mailman/rest/configure.zcml b/src/mailman/rest/configure.zcml
index 79e8ba0e7..143392499 100644
--- a/src/mailman/rest/configure.zcml
+++ b/src/mailman/rest/configure.zcml
@@ -34,6 +34,13 @@
factory="mailman.rest.urls.FallbackURLMapper"
/>
+ <adapter
+ for="mailman.interfaces.mailinglist.IMailingList
+ mailman.rest.webservice.AdminWebServiceRequest"
+ provides="zope.traversing.browser.interfaces.IAbsoluteURL"
+ factory="mailman.rest.urls.MailingListURLMapper"
+ />
+
<utility
factory="mailman.rest.configuration.AdminWebServiceConfiguration"
provides="lazr.restful.interfaces.IWebServiceConfiguration">
diff --git a/src/mailman/rest/docs/lists.txt b/src/mailman/rest/docs/lists.txt
index 64645e8e0..d877a4cec 100644
--- a/src/mailman/rest/docs/lists.txt
+++ b/src/mailman/rest/docs/lists.txt
@@ -10,3 +10,23 @@ yet though.
resource_type_link: http://localhost:8001/3.0/#mailing_lists
start: None
total_size: 0
+
+Create a mailing list in a domain and it's accessible via the API.
+
+ >>> from mailman.app.lifecycle import create_list
+ >>> create_list('test-one@example.com')
+ <mailing list "test-one@example.com" at ...>
+ >>> transaction.commit()
+
+ >>> dump_json('http://localhost:8001/3.0/lists')
+ entry 0:
+ fqdn_listname: test-one@example.com
+ host_name: example.com
+ http_etag: "..."
+ list_name: test-one
+ real_name: Test-one
+ resource_type_link: http://localhost:8001/3.0/#mailing_list
+ self_link: http://localhost:8001/3.0/mailing_lists/test-one@example.com
+ resource_type_link: http://localhost:8001/3.0/#mailing_lists
+ start: 0
+ total_size: 1
diff --git a/src/mailman/rest/urls.py b/src/mailman/rest/urls.py
index 38f676c7f..f1677421d 100644
--- a/src/mailman/rest/urls.py
+++ b/src/mailman/rest/urls.py
@@ -21,8 +21,8 @@ from __future__ import absolute_import, unicode_literals
__metaclass__ = type
__all__ = [
- 'AbsoluteURLMapper',
'DomainURLMapper',
+ 'MailingListURLMapper',
]
@@ -82,19 +82,35 @@ class FallbackURLMapper(BasicURLMapper):
return ''
urls = {
system: 'system',
- #config.db.list_manager: 'lists',
+ config.db.list_manager: 'lists',
}
return urls[ob]
-class DomainURLMapper(BasicURLMapper):
- """Mapper of `IDomains` to `IAbsoluteURL`."""
+class TopLevelURLMapper(BasicURLMapper):
+ """A simple mapper for top level objects."""
implements(IAbsoluteURL)
+ format_string = None
+
def __call__(self):
- """Return the hard-coded URL to the domain."""
- return ('{0.schema}://{0.hostname}:{0.port}/{0.version}/domains/'
- '{1.email_host}').format(self, self.context)
-
+ """Return the hard-coded URL to the resource."""
+ return self.format_string.format(self)
+
+
+class DomainURLMapper(TopLevelURLMapper):
+ """Mapper of `IDomains` to `IAbsoluteURL`."""
+
+ format_string = (
+ '{0.schema}://{0.hostname}:{0.port}/{0.version}/'
+ 'domains/{0.context.email_host}')
+
+
+class MailingListURLMapper(TopLevelURLMapper):
+ """Mapper of `IMailingList` to `IAbsoluteURL`."""
+
+ format_string = (
+ '{0.schema}://{0.hostname}:{0.port}/{0.version}/'
+ 'mailing_lists/{0.context.fqdn_listname}')