6e85c54a2e
Keep Isso modular, not monolithic. Make it easy to integrate a web interface or add XMPP notifications. This refactorization includes minor bugfixes and changes: * CORS middleware did not work properly due to wrong unit tests * more type checks on JSON input * new detection for origin and public url, closes #28 * new activation and delete url (no redirect for old urls, but you can convert the old urls: copy hash after `/activate/` (or delete) and open `/id/<id of comment>/activate/<hash>` * move crypto.py to utils/ With this commit, SMTP is no longer automatically configured: add `notify = smtp` to the `[general]` section to use SMTP.
18 lines
441 B
Python
18 lines
441 B
Python
# -*- encoding: utf-8 -*-
|
|
|
|
from collections import defaultdict
|
|
|
|
|
|
class Signal(object):
|
|
|
|
def __init__(self, *subscriber):
|
|
self.subscriptions = defaultdict(list)
|
|
|
|
for sub in subscriber:
|
|
for signal, func in sub:
|
|
self.subscriptions[signal].append(func)
|
|
|
|
def __call__(self, origin, *args, **kwargs):
|
|
for subscriber in self.subscriptions[origin]:
|
|
subscriber(*args, **kwargs)
|