blob: 5245a95d7a1ae9f7109e642c3a3e7024079b17a4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
"""A PGP plugin for GNU Mailman."""
from mailman.interfaces.listmanager import ListDeletedEvent
from mailman.interfaces.plugin import IPlugin
from public import public
from zope.event import classhandler
from zope.interface import implementer
from mailman_pgp.config import config
from mailman_pgp.database import Database, transaction
from mailman_pgp.model.list import EncryptedMailingList
from mailman_pgp.pgp import GPG
from mailman_pgp.rest.root import RESTRoot
@public
@implementer(IPlugin)
class PGPMailman:
def pre_hook(self):
"""See `IPlugin`."""
config.load(self.name)
config.db = Database()
config.gpg = GPG()
def post_hook(self):
"""See `IPlugin`."""
pass
def rest_object(self):
"""See `IPlugin`."""
return RESTRoot()
@classhandler.handler(ListDeletedEvent)
def on_delete(mlist):
encrypted_list = config.db.session.query(EncryptedMailingList).filter_by(
list_id=mlist.list_id).first()
if encrypted_list:
with transaction():
config.db.session.delete(encrypted_list)
# TODO delete the keypairs here
|