diff options
| author | Barry Warsaw | 2009-06-29 23:31:51 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2009-06-29 23:31:51 -0400 |
| commit | 9e97e8ae31450ce6a308f700fc358710462c01f8 (patch) | |
| tree | 9e8ac199065e7c1736c3d0672dadc235ea7897f0 | |
| parent | b4679d8d402348a76899dc9aedb0d515529203aa (diff) | |
| download | mailman-9e97e8ae31450ce6a308f700fc358710462c01f8.tar.gz mailman-9e97e8ae31450ce6a308f700fc358710462c01f8.tar.zst mailman-9e97e8ae31450ce6a308f700fc358710462c01f8.zip | |
| -rw-r--r-- | src/mailman/rest/adapters.py | 11 | ||||
| -rw-r--r-- | src/mailman/rest/docs/domains.txt | 77 |
2 files changed, 87 insertions, 1 deletions
diff --git a/src/mailman/rest/adapters.py b/src/mailman/rest/adapters.py index 611e1f976..b74028eaa 100644 --- a/src/mailman/rest/adapters.py +++ b/src/mailman/rest/adapters.py @@ -26,15 +26,17 @@ __all__ = [ from zope.interface import implements +from zope.publisher.interfaces import NotFound from mailman.interfaces.domain import IDomainSet +from mailman.interfaces.rest import IResolvePathNames class DomainSet: """Sets of known domains.""" - implements(IDomainSet) + implements(IDomainSet, IResolvePathNames) __name__ = 'domains' @@ -45,3 +47,10 @@ class DomainSet: """See `IDomainSet`.""" domains = self._config.domains return [domains[domain] for domain in sorted(domains)] + + def get(self, name): + """See `IResolvePathNames`.""" + domain = self._config.domains.get(name) + if domain is None: + raise NotFound(self, name) + return domain diff --git a/src/mailman/rest/docs/domains.txt b/src/mailman/rest/docs/domains.txt index 64f41d4c0..335916a61 100644 --- a/src/mailman/rest/docs/domains.txt +++ b/src/mailman/rest/docs/domains.txt @@ -17,3 +17,80 @@ The REST API can be queried for the set of known domains. resource_type_link: https://localhost:8001/3.0/#domains start: 0 total_size: 1 + +All domains are returned. + + >>> from mailman.config import config + >>> config.push('test domains', """\ + ... [domain.example_dot_org] + ... email_host: example.org + ... base_url: http://mail.example.org + ... contact_address: listmaster@example.org + ... + ... [domain.example_dot_net] + ... email_host: lists.example.net + ... base_url: http://example.net + ... contact_address: porkmaster@example.net + ... """) + + >>> dump_json('http://localhost:8001/3.0/domains') + entry 0: + base_url: http://lists.example.com + contact_address: postmaster@example.com + description: An example domain. + email_host: example.com + http_etag: "546791f38192b347db544481f1386d33607ccf3d" + resource_type_link: https://localhost:8001/3.0/#domain + self_link: https://localhost:8001/3.0/domains/example.com + url_host: lists.example.com + entry 1: + base_url: http://mail.example.org + contact_address: listmaster@example.org + description: An example domain. + email_host: example.org + http_etag: "4ff00fefca81b99ce2c7e6c50223107daf0649ff" + resource_type_link: https://localhost:8001/3.0/#domain + self_link: https://localhost:8001/3.0/domains/example.org + url_host: mail.example.org + entry 2: + base_url: http://example.net + contact_address: porkmaster@example.net + description: An example domain. + email_host: lists.example.net + http_etag: "aa5a388197948f21b8a3eb940b6c9725c5f41fac" + resource_type_link: https://localhost:8001/3.0/#domain + self_link: https://localhost:8001/3.0/domains/lists.example.net + url_host: example.net + resource_type_link: https://localhost:8001/3.0/#domains + start: 0 + total_size: 3 + + +Individual domains +================== + +The information for a single domain is available by following one of the +self_links from the above collection. + + >>> dump_json('http://localhost:8001/3.0/domains/lists.example.net') + base_url: http://example.net + contact_address: porkmaster@example.net + description: An example domain. + email_host: lists.example.net + http_etag: "aa5a388197948f21b8a3eb940b6c9725c5f41fac" + resource_type_link: https://localhost:8001/3.0/#domain + self_link: https://localhost:8001/3.0/domains/lists.example.net + url_host: example.net + +But we get a 404 for a non-existent domain. + + >>> dump_json('http://localhost:8001/3.0/domains/does-not-exist') + Traceback (most recent call last): + ... + HTTPError: HTTP Error 404: Not Found + + +Clean up +======== + + >>> config.pop('test domains') |
