Philip Iezzi
Philip Iezzi

Reputation: 71

Accessing Mailman 3 list members via Python/Django management console

I am trying to access members of an existing Mailman 3 mailing list directly from Django Management console on a Debian Bullseye where Mailman is installed from deb packages (mailman3-full). I can connect to the Django admin console like this (all 3 variants seem to work fine):

$ /usr/share/mailman3-web/manage.py shell
$ mailman-web shell
$ mailman-web shell --settings /etc/mailman3/mailman-web.py
Python 3.9.2 (default, Feb 28 2021, 17:03:44)
>>> 

But inside the Django admin console, some mailman components seem to be missing.

I try to access the list manager as described here: Docs > Models > The mailing list manager:

>>> from mailman.interfaces.listmanager import IListManager
>>> from zope.component import getUtility
>>> list_manager = getUtility(IListManager)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/zope/component/_api.py", line 169, in getUtility
    raise ComponentLookupError(interface, name)
zope.interface.interfaces.ComponentLookupError: (<InterfaceClass mailman.interfaces.listmanager.IListManager>, '')

Can't figure out why this ComponentLookupError happens.

Also tried to acccess a list with the ListManager implementation:

>>> from mailman.config import config
>>> from mailman.model.listmanager import ListManager
>>> list_manager = ListManager()

>>> list_manager.get('[email protected]')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/mailman/database/transaction.py", line 85, in wrapper
    return function(args[0], config.db.store, *args[1:], **kws)
AttributeError: 'NoneType' object has no attribute 'store'

>>> list_manager.get_by_list_id('mynews.example.com')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/mailman/database/transaction.py", line 85, in wrapper
    return function(args[0], config.db.store, *args[1:], **kws)
AttributeError: 'NoneType' object has no attribute 'store'

What am I doing wrong here? None of the examples in the Mailman 3 models documentation is working if I don't even get that far.

any help greatly appreciated!

Upvotes: 0

Views: 624

Answers (1)

Mailman3.com
Mailman3.com

Reputation: 76

It's just the wrong shell you are using. You should use Mailman core shell instead.

It is accessible via just mailman shell in your system most probably.

Upvotes: 1

Related Questions