30 lines
879 B
Python
30 lines
879 B
Python
from ..AbstractTransaction import AbstractTransaction
|
|
|
|
from zope import component
|
|
|
|
from ceo_common.interfaces import IMailmanService
|
|
|
|
|
|
class UnsubscribeMemberTransaction(AbstractTransaction):
|
|
"""Transaction to unsubscribe a member from a mailing list."""
|
|
|
|
operations = [
|
|
'unsubscribe_from_mailing_list',
|
|
]
|
|
|
|
def __init__(self, address: str, mailing_list: str):
|
|
"""
|
|
:param address: a username or email address
|
|
:param mailing_list: the list from which the user will be unsubscribed
|
|
"""
|
|
super().__init__()
|
|
self.address = address
|
|
self.mailing_list = mailing_list
|
|
self.mailman_srv = component.getUtility(IMailmanService)
|
|
|
|
def child_execute_iter(self):
|
|
self.mailman_srv.unsubscribe(self.address, self.mailing_list)
|
|
yield 'unsubscribe_to_mailing_list'
|
|
|
|
self.finish('OK')
|