[Mailman-Developers] Python 3

Barry Warsaw barry at python.org
Sat Dec 27 05:08:20 CET 2014

On Dec 26, 2014, at 11:02 PM, Aurelien Bompard wrote:

>> But there could be!  I took a very quick look at HK (but not KittyStore)
>> and it doesn't look like you need much.  What if I added a REST API to
>> access the core's system configuration settings?
>That would work.

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
    sender_headers: from from_ reply-to sender
    site_owner: noreply at 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.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/mailman-developers/attachments/20141226/88a24922/attachment.sig>

More information about the Mailman-Developers mailing list