diff options
| author | Barry Warsaw | 2009-07-25 00:23:01 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2009-07-25 00:23:01 -0400 |
| commit | 9c5c394a0912b56dd0fa1cabe07833aca24b92ef (patch) | |
| tree | 05a626a418ba364d64c2da54f0f91b6bf3001e25 /src | |
| parent | 95163b905be9c912f640b07353451013bd6020a7 (diff) | |
| download | mailman-9c5c394a0912b56dd0fa1cabe07833aca24b92ef.tar.gz mailman-9c5c394a0912b56dd0fa1cabe07833aca24b92ef.tar.zst mailman-9c5c394a0912b56dd0fa1cabe07833aca24b92ef.zip | |
Diffstat (limited to 'src')
| -rw-r--r-- | src/mailman/interfaces/mailinglist.py | 14 | ||||
| -rw-r--r-- | src/mailman/rest/configure.zcml | 7 | ||||
| -rw-r--r-- | src/mailman/rest/docs/lists.txt | 20 | ||||
| -rw-r--r-- | src/mailman/rest/urls.py | 32 |
4 files changed, 59 insertions, 14 deletions
diff --git a/src/mailman/interfaces/mailinglist.py b/src/mailman/interfaces/mailinglist.py index 0717ab2e6..28094da45 100644 --- a/src/mailman/interfaces/mailinglist.py +++ b/src/mailman/interfaces/mailinglist.py @@ -76,7 +76,7 @@ class IMailingList(Interface): # List identity list_name = exported(TextLine( - title=_("The mailing list's short name"), + title=_('Short name'), description=_("""\ The read-only short name of the mailing list. Note that where a Mailman installation supports multiple domains, this short name may @@ -87,7 +87,7 @@ class IMailingList(Interface): """))) host_name = exported(TextLine( - title=_("The mailing list's host name"), + title=_('Host name'), description=_("""\ The read-only domain name 'hosting' this mailing list. This is always the domain name part of the posting email address, and it may bear no @@ -97,7 +97,7 @@ class IMailingList(Interface): """))) fqdn_listname = exported(TextLine( - title=_("The mailing list's filly qualified name"), + title=_('Fully qualified list name'), description=_("""\ The read-only fully qualified name of the mailing list. This is the guaranteed unique id for the mailing list, and it is always the @@ -105,12 +105,14 @@ class IMailingList(Interface): always comprised of the list_name + '@' + host_name. """))) - real_name = Attribute( - """The short human-readable descriptive name for the mailing list. By + real_name = exported(TextLine( + title=_('Real name'), + description=_("""\ + The short human-readable descriptive name for the mailing list. By default, this is the capitalized `list_name`, but it can be changed to anything. This is used in locations such as the message footers and Subject prefix. - """) + """))) list_id = Attribute( """The RFC 2919 List-ID header value.""") 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}') |
