diff options
author | VG <vg@devys.org> | 2016-05-20 17:54:04 +0200 |
---|---|---|
committer | VG <vg@devys.org> | 2016-05-20 17:54:04 +0200 |
commit | 9a1f49a5a1de49496d72c1f5e184b5441183d00d (patch) | |
tree | de4d5c8fc84bab295bdd9bf1837d33416d78924e | |
parent | f9367c4da5e48ab597262093ca34536e2198a343 (diff) | |
download | climl-9a1f49a5a1de49496d72c1f5e184b5441183d00d.tar.gz climl-9a1f49a5a1de49496d72c1f5e184b5441183d00d.tar.bz2 climl-9a1f49a5a1de49496d72c1f5e184b5441183d00d.zip |
add a number of steps/hooks
-rw-r--r-- | climl/__init__.py | 16 | ||||
-rw-r--r-- | climl/interface.py | 8 |
2 files changed, 24 insertions, 0 deletions
diff --git a/climl/__init__.py b/climl/__init__.py index cb1f129..c16218f 100644 --- a/climl/__init__.py +++ b/climl/__init__.py @@ -4,10 +4,26 @@ from . import hooks def on_email(content): print('on_email:', content) + context = {} + try: + for hook in hooks: + context, content = hook(context, content) + except interface.HookStopIteration(): + pass print('now, raising exception') raise interface.HookAbortError() def main(): + # TODO: how to load hooks with a dependency tree and sort them accordingly + # to generate hooks list ? + # now try a fixed list ? + hooks = ( + hook_check_ml_restrictions, + hook_validate_poster, + hook_process_subscribe_queries, + hook_generate_rcpt_list, + hook_send_all, + ) print('starting imap.main loop') try: imap.main(on_email) diff --git a/climl/interface.py b/climl/interface.py index 5a7f6ba..549eb8b 100644 --- a/climl/interface.py +++ b/climl/interface.py @@ -17,3 +17,11 @@ class HookAbortError(HookError): ''' pass + +class HookAbortError(HookError, StopIteration): + ''' + Run this if your hook declares it does not want other hooks to process + email. + ''' + + pass |