diff options
| author | Barry Warsaw | 2010-08-10 18:26:18 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2010-08-10 18:26:18 -0400 |
| commit | 02ac6590baaad126be1f6154794bce5ccecaaf99 (patch) | |
| tree | e8a00e21cb751b5c7c431ef1d30ef3db2ab9bb97 /src/mailman/rest/lists.py | |
| parent | e610dac8966ea1a0f09735a5bd249efd7b8060cb (diff) | |
| download | mailman-02ac6590baaad126be1f6154794bce5ccecaaf99.tar.gz mailman-02ac6590baaad126be1f6154794bce5ccecaaf99.tar.zst mailman-02ac6590baaad126be1f6154794bce5ccecaaf99.zip | |
Access mailing list configuration via REST
* last_post_time -> last_post_at
* protocol -> scheme
* creation_date _> created_at
* last_post_time -> last_post_at
* Add an extended JSON encoder for datetimes
* Be sure to initialize convert_html_to_plaintext and filter_content in the
default style.
Diffstat (limited to 'src/mailman/rest/lists.py')
| -rw-r--r-- | src/mailman/rest/lists.py | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/src/mailman/rest/lists.py b/src/mailman/rest/lists.py index ddda613c9..a9d894714 100644 --- a/src/mailman/rest/lists.py +++ b/src/mailman/rest/lists.py @@ -23,6 +23,7 @@ __metaclass__ = type __all__ = [ 'AList', 'AllLists', + 'ListConfiguration', ] @@ -80,6 +81,18 @@ def roster_matcher(request, segments): return None +@restish_matcher +def config_matcher(request, segments): + """A matcher for a mailing list's configuration resource. + + e.g. /config + """ + if len(segments) == 1 and segments[0] == 'config': + return (), {}, () + # It's something else. + return None + + class _ListBase(resource.Resource, CollectionMixin): """Shared base class for mailing list representations.""" @@ -133,7 +146,13 @@ class AList(_ListBase): """Return the collection of all a mailing list's members.""" return MembersOfList(self._mlist, role) + @resource.child(config_matcher) + def config(self, request, segments): + """Return a mailing list configuration object.""" + return ListConfiguration(self._mlist) + + class AllLists(_ListBase): """The mailing lists.""" @@ -160,3 +179,55 @@ class AllLists(_ListBase): """/lists""" resource = self._make_collection(request) return http.ok([], etag(resource)) + + + +class ListConfiguration(resource.Resource): + """A mailing list configuration resource.""" + + def __init__(self, mailing_list): + self._mlist = mailing_list + + @resource.GET() + def configuration(self, request): + """Return a mailing list's readable configuration.""" + # The set of readable IMailingList attributes. + readable=( + # Identity. + 'created_at', + 'list_name', + 'host_name', + 'fqdn_listname', + 'real_name', + 'list_id', + 'include_list_post_header', + 'include_rfc2369_headers', + # Contact addresses. + 'posting_address', + 'no_reply_address', + 'owner_address', + 'request_address', + 'bounces_address', + 'join_address', + 'leave_address', + # Posting history. + 'last_post_at', + 'post_id', + # Digests. + 'digest_last_sent_at', + 'volume', + 'next_digest_number', + 'digest_size_threshold', + # Web access. + 'scheme', + 'web_host', + # Processing. + 'pipeline', + 'filter_content', + 'convert_html_to_plaintext', + 'collapse_alternatives', + ) + resource = {} + for attribute in readable: + resource[attribute] = getattr(self._mlist, attribute) + return http.ok([], etag(resource)) |
