[Mailman-Developers] Re: Creating an event catching plugin

2022-03-08 Thread Дилян Палаузов
Hello,

the object passed was actually an unsubscription/subscription event,
which was just pretty-printed.

Is there any explanation, why in the code below YYY is not printed?

when I add

def pre_hook(self):
print('pre_HOOK')


pre_HOOK is also not printed, but __init__ is called, as XXX is
printed.

Greetings
  Дилян

On Tue, 2022-03-08 at 19:39 +0200, Дилян Палаузов wrote:
> Hello,
> 
> can you point me to existing, open-source mailman plugins?
> 
> I want to write a plugin, which fires on all subscriptions,
> unsubscriptions and configuration changes.
> 
> This code:
> 
> def subscribe_events(e):
>     print('EVENT', e)
> 
> @implementer(IPlugin)
> class SievePlugin:
>     def __init__(self):
>     print('XXX')
>     zope.event.subscribers.append(subscribe_events)
> 
>     def post_hook(self):
>     print('YYY')
>     zope.event.subscribers.append(subscribe_events)
> 
> 
> prints:
> XXX
> EVENT x...@example.org joined zzz.udoma.bapha.be
> EVENT ab c  joined zzz.udoma.bapha.be
> 
> or 
> XXX
> EVENT x...@example.org left zzz.udoma.bapha.be
> 
> on `mailman addmembers/mailman delmembers`.  But it does not trigger
> a
> UnsubscriptionEvent or SubscriptionEvent.
> 
> Greetings
>   Дилян

___
Mailman-Developers mailing list -- mailman-developers@python.org
To unsubscribe send an email to mailman-developers-le...@python.org
https://mail.python.org/mailman3/lists/mailman-developers.python.org/
Mailman FAQ: https://wiki.list.org/x/AgA3

Security Policy: https://wiki.list.org/x/QIA9


[Mailman-Developers] Creating an event catching plugin

2022-03-08 Thread Дилян Палаузов
Hello,

can you point me to existing, open-source mailman plugins?

I want to write a plugin, which fires on all subscriptions,
unsubscriptions and configuration changes.

This code:

def subscribe_events(e):
print('EVENT', e)

@implementer(IPlugin)
class SievePlugin:
def __init__(self):
print('XXX')
zope.event.subscribers.append(subscribe_events)

def post_hook(self):
print('YYY')
zope.event.subscribers.append(subscribe_events)


prints:
XXX
EVENT x...@example.org joined zzz.udoma.bapha.be
EVENT ab c  joined zzz.udoma.bapha.be

or 
XXX
EVENT x...@example.org left zzz.udoma.bapha.be

on `mailman addmembers/mailman delmembers`.  But it does not trigger a
UnsubscriptionEvent or SubscriptionEvent.

Greetings
  Дилян
___
Mailman-Developers mailing list -- mailman-developers@python.org
To unsubscribe send an email to mailman-developers-le...@python.org
https://mail.python.org/mailman3/lists/mailman-developers.python.org/
Mailman FAQ: https://wiki.list.org/x/AgA3

Security Policy: https://wiki.list.org/x/QIA9