How to create (or change) certain member preferences (in a list, or for all lists) by command line "mailman create [OPTIONS] LISTNAME" ? (Suggestion: modification of this command)

Some member preferences - such as hide_address - cannot be set with the [OPTIONS] in the command line.
I suggest to modify the code so that all member preferences can be set via the command line. What do you think?
This is how I currently patch (some) member preferences (hide_address is a variable here) in a python script, but this takes a lot of time, depending on the number of users.... YMMV.
patch_url = f"{member['self_link']}/preferences"
patch_data = {
"acknowledge_posts": True,
"hide_address": hide_address,
"preferred_language": "de",
"receive_list_copy": True,
"receive_own_postings": True,
"delivery_mode": "regular", # accepted values are: regular, plaintext_digests, mime_digests, summary_digests
"delivery_status": delivery_status # accepted values are: enabled, by_user, by_bounces, by_moderator, unknown
}
r = requests.patch(patch_url, json=patch_data, auth=AUTH, headers=HEADERS)

On 8/4/25 12:09, Wikinaut wrote:
Some member preferences - such as hide_address - cannot be set with the [OPTIONS] in the command line.
I suggest to modify the code so that all member preferences can be set via the command line. What do you think?
This is how I currently patch (some) member preferences (hide_address is a variable here) in a python script, but this takes a lot of time, depending on the number of users.... YMMV.
If you do this via a mailman shell
script rather than the REST API, it
should be significantly faster as it will avoid the per-user network
connections.
Note that changing various list options such as preferred_language does not affect existing members.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan

Wikinaut writes:
I suggest to modify the code so that all member preferences can be set via the command line.
They already can be set via "mailman shell", and common settings can be automated using a withlist script.
What do you think?
User preferences are extremely complicated because they can be set at several levels. If you know what you're doing Mailman-wise, it requires very little Python to script it (and most of the folks here can help those who don't have that much yet, it doesn't take a core developer). If you don't, the web UI is much better because it is already contains documentation and is more suitable for maintaining that documentation.
If you want to provide a patch and commit to documenting it and maintaining it for say 5 years (I do *not* recommend this for the same reasons I really really don't want to do it myself ;-), I promise to review it.
It might be interesting to provide a batch API in REST where you could provide an arbitrary sequence of changes in JSON format to address the efficiency problem, but that would be a big project. I haven't thought carefully about it so no promises there.
-- GNU Mailman consultant (installation, migration, customization) Sirius Open Source https://www.siriusopensource.com/ Software systems consulting in Europe, North America, and Japan

Dear Stephen and Mark, thank you for your helpful swift answers.
I am currently working on a complete set of "create Mailinglists, configure MLs, addMembers, patchMemberPreference" suite and will publish that soon, probably on github or so. Everything now already works via REST-API only, but takes 0.25 seconds per action. Some steps in the workflow require 2 actions. So currently it takes already many minutes (using only REST) for 4 lists with 500 members. But I have twenty, thus...
...after having learned that mailman3 also has some command line command (mailman create, remove, addmembers, syncmembers similar to the old mailman2 commands), I am currently phasing out those costly REST actions to mere mailman commands and only "patch" the remaing things.
This hybrid approach is much quicker.
As mentioned above, I will publish the tool chain (suite) later somewhere and close my related questions (here in the mailing list) with a pointer to the code.
Thanks for mailman3.
participants (3)
-
Mark Sapiro
-
Stephen J. Turnbull
-
Wikinaut