On 10/17/24 15:06, Andy Matthews wrote:
Hey Mark, I'm looking at the documentation here: https://docs.mailman3.org/projects/mailman/en/latest/src/mailman/model/docs/...
Which seems to indicate that adding a domain via the CLI is as easy as:
from mailman.interfaces.domain import IDomainManager from zope.component import getUtility manager = getUtility(IDomainManager) manager.add('example.org')
It's not until much further down the page that there's any reference to "committing" a change. But sure enough when I add the following three lines to the previous 4, I'm able to create a mailing list with staging.mydomain.dev using the REST API.
from mailman.config import config transaction = config.db transaction.commit()
I don't know how you are running these Python interactions, but if you
are using mailman shell
interactively, things like IDomainManager, and
getUtility and lots of other things are imported automatically and
commit() and abort() are also predefined.
I created an issue suggesting as much on GitLab: https://gitlab.com/mailman/mailman/-/issues/1178
Also when using mailman shell
, at startup it says:
Welcome to the GNU Mailman shell
Use commit() to commit changes.
Use abort() to discard changes since the last commit.
Exit with ctrl+D does an implicit commit() but exit() does not.
I've seen issue #1178. The issue is actually more widespread than that.
There are lots of things done in the Python snippets in the docs to
support the fact that they are all actually run as doctests as part of
our CI to ensure they are correct. In practice it is generally easier to
run these in mailman shell
. However, the docs themselves don't say that.
We say a bit at https://docs.mailman3.org/projects/mailman/en/latest/src/mailman/commands/do... but I don't know a good way to say that globally.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan