diff options
| author | Barry Warsaw | 2009-08-07 23:46:41 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2009-08-07 23:46:41 -0400 |
| commit | c34682f40fabd9001c775f34fd082b9c00b7f96a (patch) | |
| tree | 62b0ad4333e6eb527067a1325389ab653517a05f | |
| parent | 1b21af1df7e39a86cf8cebea2ea99eece93fdfd7 (diff) | |
| download | mailman-c34682f40fabd9001c775f34fd082b9c00b7f96a.tar.gz mailman-c34682f40fabd9001c775f34fd082b9c00b7f96a.tar.zst mailman-c34682f40fabd9001c775f34fd082b9c00b7f96a.zip | |
| -rw-r--r-- | src/mailman/database/listmanager.py | 3 | ||||
| -rw-r--r-- | src/mailman/interfaces/mailinglist.py | 5 | ||||
| -rw-r--r-- | src/mailman/rest/docs/lists.txt | 29 | ||||
| -rw-r--r-- | src/mailman/rest/urls.py | 2 |
4 files changed, 29 insertions, 10 deletions
diff --git a/src/mailman/database/listmanager.py b/src/mailman/database/listmanager.py index 6410d9198..f96e44d75 100644 --- a/src/mailman/database/listmanager.py +++ b/src/mailman/database/listmanager.py @@ -32,13 +32,14 @@ from zope.interface import implements from mailman.config import config from mailman.database.mailinglist import MailingList from mailman.interfaces.listmanager import IListManager, ListAlreadyExistsError +from mailman.interfaces.rest import IResolvePathNames class ListManager(object): """An implementation of the `IListManager` interface.""" - implements(IListManager) + implements(IListManager, IResolvePathNames) # pylint: disable-msg=R0201 def create(self, fqdn_listname): diff --git a/src/mailman/interfaces/mailinglist.py b/src/mailman/interfaces/mailinglist.py index 28094da45..a2bd29e36 100644 --- a/src/mailman/interfaces/mailinglist.py +++ b/src/mailman/interfaces/mailinglist.py @@ -71,7 +71,10 @@ class DigestFrequency(Enum): class IMailingList(Interface): """A mailing list.""" - export_as_webservice_entry() + # Use a different singular and plural name for the resource type than + # lazr.restful gives it as a default (which is normally taken from the + # interface name). + export_as_webservice_entry('list', 'lists') # List identity diff --git a/src/mailman/rest/docs/lists.txt b/src/mailman/rest/docs/lists.txt index 5b8c6bc5b..790ea02ba 100644 --- a/src/mailman/rest/docs/lists.txt +++ b/src/mailman/rest/docs/lists.txt @@ -7,7 +7,7 @@ top level collection that can return all the mailing lists. There aren't any yet though. >>> dump_json('http://localhost:8001/3.0/lists') - resource_type_link: http://localhost:8001/3.0/#mailing_lists + resource_type_link: http://localhost:8001/3.0/#lists start: None total_size: 0 @@ -25,9 +25,9 @@ Create a mailing list in a domain and it's accessible via the API. 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 + resource_type_link: http://localhost:8001/3.0/#list + self_link: http://localhost:8001/3.0/lists/test-one@example.com + resource_type_link: http://localhost:8001/3.0/#lists start: 0 total_size: 1 @@ -36,8 +36,8 @@ Creating lists via the API ========================== New mailing lists can also be created through the API, by posting to the -'mailing_lists' URL. However lazr.restful requires us to use a 'named -operation' instead of posting directly to the URL. +'lists' URL. However lazr.restful requires us to use a 'named operation' +instead of posting directly to the URL. >>> dump_json('http://localhost:8001/3.0/lists', { ... 'ws.op': 'new', @@ -47,7 +47,7 @@ operation' instead of posting directly to the URL. content-length: 0 content-type: text/plain date: ... - location: http://localhost:8001/3.0/mailing_lists/test-two@example.com + location: http://localhost:8001/3.0/lists/test-two@example.com server: WSGIServer/... Python/... x-content-type-warning: guessed from content x-powered-by: Zope (www.zope.org), Python (www.python.org) @@ -57,6 +57,21 @@ The mailing list exists in the database. >>> config.db.list_manager.get('test-two@example.com') <mailing list "test-two@example.com" at ...> + # The above starts a Storm transaction, which will lock the database + # unless we abort it. + >>> transaction.abort() + +It is also available via the location given in the response. + + >>> dump_json('http://localhost:8001/3.0/lists/test-two@example.com') + fqdn_listname: test-two@example.com + host_name: example.com + http_etag: "..." + list_name: test-two + real_name: Test-two + resource_type_link: http://localhost:8001/3.0/#list + self_link: http://localhost:8001/3.0/lists/test-two@example.com + However, you are not allowed to create a mailing list in a domain that does not exist. diff --git a/src/mailman/rest/urls.py b/src/mailman/rest/urls.py index 16b98ea68..a0b871aa0 100644 --- a/src/mailman/rest/urls.py +++ b/src/mailman/rest/urls.py @@ -112,4 +112,4 @@ class MailingListURLMapper(TopLevelURLMapper): format_string = ( '{0.schema}://{0.hostname}:{0.port}/{0.version}/' - 'mailing_lists/{0.context.fqdn_listname}') + 'lists/{0.context.fqdn_listname}') |
