On 3/31/23 14:17, Andrew Hodgson wrote:
Hi.
Has anyone managed to get this script running using the Mailman-Web setup in a venv? It was working when Settings.py was in the /opt/mailman/mm directory but since moving to Mailman-Web has it in /etc/mailman3. I have been trying to import Mailman-Web to get the Django environment running but every time I do this I get a not configured exception raised.
First, get the latest version of the script from https://www.msapiro.net/scripts/clean_users.py - not the one in this threat attached to https://lists.mailman3.org/archives/list/mailman-users@mailman3.org/message/... Then, you need to change `/opt/mailman/mm` in three places to `/etc/mailman3` as in ``` --- /opt/mailman/mm/bin/clean_users.py 2021-05-08 20:03:31.657565251 -0700 +++ clean_users.py 2023-03-31 15:48:31.772383287 -0700 @@ -2,13 +2,13 @@ import os import sys -sys.path.insert(0, '/opt/mailman/mm') +sys.path.insert(0, '/etc/mailman3') # The above line is required. The next line doesn't hurt, but it doesn't work # because the PYTHONPATH environment setting is processed by Python's setup # and must be in the environment when Python starts to be effective. -os.environ['PYTHONPATH'] = '/opt/mailman/mm' +os.environ['PYTHONPATH'] = '/etc/mailman3' os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' -os.environ['MAILMAN_CONFIG_FILE'] = '/opt/mailman/mm/mailman.cfg' +os.environ['MAILMAN_CONFIG_FILE'] = '/etc/mailman3/mailman.cfg' import django django.setup() ``` Also, look at this ``` # If we delete the Django user and there is a Mailman user with no memberships # shall we delete the Mailman user too. DELETE_MAILMAN_USER = False # Shall we delete the Django user if there is a Mailman user with no # memberships or only if there is no Mailman user. DELETE_DJANGO_IF_MAILMAN = True ``` and consider whether you want to set `DELETE_MAILMAN_USER = True` to also delete the Mailman user if any, and/or set `DELETE_DJANGO_IF_MAILMAN = False` to not delete the django user if there is a Mailman user with no memberships. -- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan