How to create a list with → advertised=false ← by command line "mailman create [OPTIONS] LISTNAME" ?

I use the following REST-API sequence (excerpt:) to create a list but want to use the much quicker command line. However, only a few [OPTIONS] can be set via command line.
Why? My wish is to have all options available in the command line of mailman?
Excerpt from my generateMailinglists.py:
# see https://docs.mailman3.org/projects/mailman/en/latest/src/mailman/rest/docs/listconf.html
updates = {
"description": f"{ML} {listname} ({NOW})",
"info": f"{ML} {listname} (autogenerated {NOW})",
"display_name": listname,
"subject_prefix": f"[{listname.upper()}] ",
"advertised": False, # the list will not be shown on mailman3 startpage
"allow_list_posts": True,
"default_nonmember_action": "discard",
"default_member_action": "accept",
"subscription_policy": "open", # accepted values are: open, confirm, moderate, confirm_then_moderate
"unsubscription_policy": "open", # accepted values are: open, confirm, moderate, confirm_then_moderate
"send_welcome_message": False,
"send_goodbye_message": False,
"archive_policy": "private", # accepted values are: public, private, never
"preferred_language": "de",
"member_roster_visibility": "members" # accepted values are: public, members, moderators
}
update_config(fqdn_listname, updates)

On 8/4/25 11:01, Wikinaut wrote:
I use the following REST-API sequence (excerpt:) to create a list but want to use the much quicker command line. However, only a few [OPTIONS] can be set via command line.
Create the list via the command line mailman create
and specify the
desired style, e.g. private-default
for a list with advertised = False
, archive_policy = ArchivePolicy.private
and
subscription_policy = SubscriptionPolicy.confirm_then_moderate
.
See https://docs.mailman3.org/projects/mailman/en/latest/src/mailman/styles/docs... for some info on styles and see https://gitlab.com/mailman/example-mailman-plugin for information on creating a plugin to configure additional list styles.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan

When I use "mailman create --style-name MYSTYLE LISTNAME", I suppose MYSTYLE must be defined before, as this cannot be read from a file.
When I use the code from https://docs.mailman3.org/projects/mailman/en/latest/src/mailman/styles/docs... before, wil the new style be defined permanently? Or only in that shell, not permanently?
I this case I kindly ask developers for small script configureList.py which can be saved and invoked as a file.
PS. I have such a script ready but as REST-API version, but certainly it's more clever and will run faster directly as python in the mailman shell environment.

Wikinaut writes:
When I use "mailman create --style-name MYSTYLE LISTNAME", I suppose MYSTYLE must be defined before, as this cannot be read from a file.
When I use the code from https://docs.mailman3.org/projects/mailman/en/latest/src/mailman/styles/docs... before, wil the new style be defined permanently? Or only in that shell, not permanently?
It only is defined for the life of that shell. That's why Mark suggests creating a plugin. See https://docs.mailman3.org/projects/mailman/en/latest/src/mailman/plugins/doc... https://gitlab.com/mailman/example-mailman-plugin # this implements a style
I this case I kindly ask developers for small script configureList.py which can be saved and invoked as a file.
You just copy the commands you invoke in "mailman shell" to a file, prefix them with "def function_with_the_same_name_as_the_file(mlist)", fix the indentation :-), and invoke it with "mailman withlist -r name_of_function -l name_of_list". I forget if the withlist script file has a .py extension or not, obviously the function doesn't.
There's actually no difference between "mailman withlist" and "mailman shell", "shell" is a trivial subclass of "withlist". Nothing except the name of the command is different.
-- GNU Mailman consultant (installation, migration, customization) Sirius Open Source https://www.siriusopensource.com/ Software systems consulting in Europe, North America, and Japan

Dear Stephen,
this was nice but is not working for me.
I edited a file with name set_user_prefs (without .py) (to preset up user preference in the whole system):
def set_members_prefs(): from zope.component import getUtility from mailman.interfaces.listmanager import IListManager from mailman.interfaces.member import DeliveryMode, DeliveryStatus hide_address = True delivery_status = DeliveryStatus.enabled lm = getUtility(IListManager) for mlist in lm.mailing_lists: for member in mlist.members.members: prefs = member.preferences prefs.acknowledge_posts = True prefs.hide_address = hide_address prefs.preferred_language = 'de' prefs.receive_list_copy = True prefs.receive_own_postings = True prefs.delivery_mode = DeliveryMode.regular prefs.delivery_status = delivery_status print(f"Updated {member.address.email} in list {mlist.fqdn_listname}")
I went to my (venv) and typed (in /opt/mailman)
$/opt/mailman: mailman withlist -r /opt/mailman/set_members_prefs or short mailman withlist -r set_members_prefs
and got
(venv) mailman@cloud:~$ mailman withlist -r /opt/mailman/set_members_prefs Traceback (most recent call last): File "/opt/mailman/venv/bin/mailman", line 8, in <module> sys.exit(main()) File "/opt/mailman/venv/lib/python3.9/site-packages/click/core.py", line 1161, in __call__ return self.main(*args, **kwargs) File "/opt/mailman/venv/lib/python3.9/site-packages/click/core.py", line 1082, in main rv = self.invoke(ctx) File "/opt/mailman/venv/lib/python3.9/site-packages/mailman/bin/mailman.py", line 69, in invoke return super().invoke(ctx) File "/opt/mailman/venv/lib/python3.9/site-packages/click/core.py", line 1697, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/opt/mailman/venv/lib/python3.9/site-packages/click/core.py", line 1443, in invoke return ctx.invoke(self.callback, **ctx.params) File "/opt/mailman/venv/lib/python3.9/site-packages/click/core.py", line 788, in invoke return __callback(*args, **kwargs) File "/opt/mailman/venv/lib/python3.9/site-packages/click/decorators.py", line 33, in new_func return f(get_current_context(), *args, **kwargs) File "/opt/mailman/venv/lib/python3.9/site-packages/mailman/commands/cli_withlist.py", line 280, in shell r = call_name(dotted_name, *run_args) File "/opt/mailman/venv/lib/python3.9/site-packages/mailman/utilities/modules.py", line 69, in call_name named_callable = find_name(dotted_name) File "/opt/mailman/venv/lib/python3.9/site-packages/mailman/utilities/modules.py", line 52, in find_name module = import_module(module_path) File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1030, in _gcd_import File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked ModuleNotFoundError: No module named '/opt/mailman/set_members_prefs'
Perhaps you know, what I did wrong, and can help with a working solution. I guess, it can help many users, too.

On 8/5/25 10:20, Wikinaut wrote:
Dear Stephen,
this was nice but is not working for me.
I edited a file with name set_user_prefs (without .py) (to preset up user preference in the whole system):
It needs a .py extension.
I went to my (venv) and typed (in /opt/mailman)
$/opt/mailman: mailman withlist -r /opt/mailman/set_members_prefs or short mailman withlist -r set_members_prefs
and got ... ModuleNotFoundError: No module named '/opt/mailman/set_members_prefs'
Perhaps you know, what I did wrong, and can help with a working solution. I guess, it can help many users, too.
The file needs a .py extension and it needs to be in a directory containing an __init__.py file. If /opt/mailman/ is not such a directory, it is better to put your script in Mailman's bin directory, e.g. /opt/mailman/venv/bin/set_members_prefs.py
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan

This approach, I already tried. No success. Also, there is no such init-File in /opt/mailman/venv/bin (Standard setup as in your documentaiton).

I tested the code in the mailman shell and it works there. So in this jigsaw puzzle, one important hint appears to be needed to get the sequence of commands running as callable script.
How?
participants (3)
-
Mark Sapiro
-
Stephen J. Turnbull
-
Wikinaut