Re: [Mailman-Developers] Python 3

On Dec 26, 2014, at 11:02 PM, Aurelien Bompard wrote:
It turned out to be almost ridiculously easy, so that probably means it's a good idea <wink>. Quoting from the documentation:
==================== System configuration
The entire system configuration is available through the REST API. You can get a list of all defined sections.
>>> dump_json('http://localhost:9001/3.0/system/configuration')
http_etag: ...
sections: ['antispam', 'archiver.mail_archive', 'archiver.master', ...
You can also get all the values for a particular section.
>>> dump_json('http://localhost:9001/3.0/system/configuration/mailman')
default_language: en
email_commands_max_lines: 10
filtered_messages_are_preservable: no
http_etag: ...
layout: testing
noreply_address: noreply
pending_request_life: 3d
post_hook:
pre_hook:
sender_headers: from from_ reply-to sender
site_owner: noreply@example.com
Dotted section names work too, for example, to get the French language settings section.
>>> dump_json('http://localhost:9001/3.0/system/configuration/language.fr')
charset: iso-8859-1
description: French
enabled: yes
http_etag: ...
-----end quote-----
Of course, these configuration resources are read-only. Also, I am
deprecating the /<api>/system
resource path; for backward compatibility this
will still return the system versions, but you'll notice that the self_link
now points to <api>/system/versions
which is the new canonical resource
path. I'll remove the old path when the API version gets rev'd.
This makes a good point though: I'm not outright discouraging applications
from using core as a library, and in fact that was part of the point of making
everything importable via the mailman
package. But I'm far from ready to
make any guarantees of stability for the internal API, including interfaces.
The REST API however I *am* making guarantees about, as evidenced by using an
API version at the root of the resource tree.
Note that configuration values are verbatim strings. You might need to convert the value to some typed data, e.g. [mailman]pending_request_lifetime has a value of '3d' which is shorthand for a timedelta. Clients must convert those data types themselves. Similarly for ints, booleans, etc. Multiline or whitespace separated strings values must be .split() by the client.
But you *do* have access to all configuration settings now, although only on the py3 branch atm.
Cheers, -Barry
participants (1)
-
Barry Warsaw