When my company migrated from MM2 to MM3, they discovered there were things 
that didn't work as expected (don't get me started). So they developed a set of 
Python functions which allowed then to fill in the missing functionality. 
However, they've discovered that some of those functions either never worked 
properly, or no longer work. For example, 

```
def list_nonmembers(mlist):
    for accepted in mlist.accept_these_nonmembers:
        print("Accepted: ",accepted)
    for held in mlist.hold_these_nonmembers:
        print("Held: ",held)
```
They're run by shelling into the machine which hosts mailman and executed like 
so (where scripts is `scripts.py`)

```
sudo -iu mailman mailman shell -l MAILING_LIST_ID --run scripts.list_nonmembers
```

I'm recommending that we install Postorius, as I suspect many of the functions 
they've written are already present in that UI, but it's not as simple as that. 
Instead they're wanting a handful of these functions (including the one listed 
above) replaced sooner than we could get Postorius up and running.

I've gotten this far:
```
from mailman.interfaces.listmanager import IListManager
from zope.component import getUtility
mylist_id = 'bravo-op...@tena-sda.org'
list_manager = getUtility(IListManager)
mylist = list_manager.get(mylist_id)
```

The mylist variable is of type `mailman.model.mailinglist.MailingList`, and 
includes an Attributes for nonmembers:
```
mylist.nonmembers
<mailman.model.roster.NonmemberRoster object at 0x7ffffa3e65b0>
```

But this nonmembers property doesn't output any users/addresses when printed, 
and throws a TypeError when I try to iterate over it:

```
Traceback (most recent call last):
  File "<console>", line 1, in <module>
TypeError: 'NonmemberRoster' object is not iterable
``` 

So, given a mailing list instance, retrieved via `list_manager.get(mylist_id)`, 
how would I go about printing all nonmembers and their current roles in a list 
(held, accepted, etc.)? Alternately, is there a different question I should be 
asking in order to retrieve that information?
_______________________________________________
Mailman-users mailing list -- mailman-users@mailman3.org
To unsubscribe send an email to mailman-users-le...@mailman3.org
https://lists.mailman3.org/mailman3/lists/mailman-users.mailman3.org/
Archived at: 
https://lists.mailman3.org/archives/list/mailman-users@mailman3.org/message/LKJMPHNVVJSFUA26ONQIZ2DVIA2CZ6BT/

This message sent to arch...@mail-archive.com

Reply via email to