summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBarry Warsaw2009-06-29 23:15:11 -0400
committerBarry Warsaw2009-06-29 23:15:11 -0400
commitb4679d8d402348a76899dc9aedb0d515529203aa (patch)
tree4eb6b3890afea708a284f6492903e8e75f986371 /src
parent5d5716d50b54efbeb60f26a184ec21118e9eae79 (diff)
downloadmailman-b4679d8d402348a76899dc9aedb0d515529203aa.tar.gz
mailman-b4679d8d402348a76899dc9aedb0d515529203aa.tar.zst
mailman-b4679d8d402348a76899dc9aedb0d515529203aa.zip
Diffstat (limited to 'src')
-rw-r--r--src/mailman/rest/configure.zcml17
-rw-r--r--src/mailman/rest/docs/domains.txt13
-rw-r--r--src/mailman/rest/publication.py3
-rw-r--r--src/mailman/rest/urls.py25
-rw-r--r--src/mailman/tests/test_documentation.py9
5 files changed, 56 insertions, 11 deletions
diff --git a/src/mailman/rest/configure.zcml b/src/mailman/rest/configure.zcml
index c6d32ac58..5d0a7c08f 100644
--- a/src/mailman/rest/configure.zcml
+++ b/src/mailman/rest/configure.zcml
@@ -12,16 +12,23 @@
<webservice:register module="mailman.interfaces.domain" />
<adapter
- for="zope.interface.Interface
+ for="mailman.config.config.IConfiguration"
+ provides="mailman.interfaces.domain.IDomainSet"
+ factory="mailman.rest.adapters.DomainSet"
+ />
+
+ <adapter
+ for="mailman.interfaces.domain.IDomain
mailman.rest.webservice.AdminWebServiceRequest"
provides="zope.traversing.browser.interfaces.IAbsoluteURL"
- factory="mailman.rest.urls.AbsoluteURLMapper"
+ factory="mailman.rest.urls.DomainURLMapper"
/>
<adapter
- for="mailman.config.config.IConfiguration"
- provides="mailman.interfaces.domain.IDomainSet"
- factory="mailman.rest.adapters.DomainSet"
+ for="zope.interface.Interface
+ mailman.rest.webservice.AdminWebServiceRequest"
+ provides="zope.traversing.browser.interfaces.IAbsoluteURL"
+ factory="mailman.rest.urls.FallbackURLMapper"
/>
<utility
diff --git a/src/mailman/rest/docs/domains.txt b/src/mailman/rest/docs/domains.txt
index e3ea902bc..64f41d4c0 100644
--- a/src/mailman/rest/docs/domains.txt
+++ b/src/mailman/rest/docs/domains.txt
@@ -5,4 +5,15 @@ Domains
The REST API can be queried for the set of known domains.
>>> dump_json('http://localhost:8001/3.0/domains')
- XXX
+ 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
+ resource_type_link: https://localhost:8001/3.0/#domains
+ start: 0
+ total_size: 1
diff --git a/src/mailman/rest/publication.py b/src/mailman/rest/publication.py
index 2334fb602..a50976102 100644
--- a/src/mailman/rest/publication.py
+++ b/src/mailman/rest/publication.py
@@ -48,7 +48,8 @@ class Publication:
def beforeTraversal(self, request):
"""See `IPublication`."""
- pass
+ endInteraction()
+ newInteraction(request)
def getApplication(self, request):
"""See `IPublication`."""
diff --git a/src/mailman/rest/urls.py b/src/mailman/rest/urls.py
index cdd921d4e..fe12a6ed8 100644
--- a/src/mailman/rest/urls.py
+++ b/src/mailman/rest/urls.py
@@ -15,13 +15,14 @@
# You should have received a copy of the GNU General Public License along with
# GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
-"""Module stuff."""
+"""Mappers from objects to absolute URLs."""
from __future__ import absolute_import, unicode_literals
__metaclass__ = type
__all__ = [
'AbsoluteURLMapper',
+ 'DomainURLMapper',
]
@@ -36,8 +37,8 @@ from mailman.rest.webservice import AdminWebServiceApplication
-class AbsoluteURLMapper:
- """Generic absolute url mapper."""
+class BasicURLMapper:
+ """Base absolute URL mapper."""
implements(IAbsoluteURL)
@@ -51,6 +52,11 @@ class AbsoluteURLMapper:
self.hostname = config.webservice.hostname
self.port = int(config.webservice.port)
+
+
+class FallbackURLMapper(BasicURLMapper):
+ """Generic absolute url mapper."""
+
def __call__(self):
"""Return the semi-hard-coded URL to the service root."""
path = self._lookup(self.context)
@@ -73,3 +79,16 @@ class AbsoluteURLMapper:
system: 'system',
}
return urls[ob]
+
+
+
+class DomainURLMapper(BasicURLMapper):
+ """Mapper of `IDomains` to `IAbsoluteURL`."""
+
+ implements(IAbsoluteURL)
+
+ 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)
+
diff --git a/src/mailman/tests/test_documentation.py b/src/mailman/tests/test_documentation.py
index 0c061e873..501b13a61 100644
--- a/src/mailman/tests/test_documentation.py
+++ b/src/mailman/tests/test_documentation.py
@@ -119,7 +119,14 @@ def dump_json(url):
finally:
fp.close()
for key in sorted(data):
- print '{0}: {1}'.format(key, data[key])
+ if key == 'entries':
+ for i, entry in enumerate(data[key]):
+ # entry is a dictionary.
+ print 'entry %d:' % i
+ for entry_key in sorted(entry):
+ print ' {0}: {1}'.format(entry_key, entry[entry_key])
+ else:
+ print '{0}: {1}'.format(key, data[key])