20 Jul
2024
20 Jul
'24
9:53 p.m.
On 7/20/24 1:27 PM, steve.bachinsky@tena-sda.org wrote:
If I know the moderator's email address, is there a way to do this in a python function?
Something like
import os
import sys
from mailman.core import initialize
from mailman.database.transaction import transaction
from mailman.interfaces.listmanager import IListManager
from zope.component import getUtility
os.environ['MAILMAN_CONFIG_FILE'] = '/path/to/mailman.cfg'
initialize.initialize()
def delete_moderator(list_id, email):
mlist = getUtility(IListManager).get_by_list_id(list_id)
if not mlist:
print(f'No such list {list_id}', file = sys.stderr)
sys.exit(1)
with transaction():
moderator = mlist.moderators.get_member(email)
if moderator:
moderator.unsubscribe()
else:
print(f'No such moderator {email}', file = sys.stderr)
sys.exit(1)
if __name__ == '__main__':
delete_moderator('list.example.comg', 'user@example.com')
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan