From 2a192dacc1162ba430f6513273a4ba2b1ab14663 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Tue, 2 Jan 2018 19:44:58 +0100 Subject: [PATCH] References to Config static getters moved from the constructor declaration to the constructor body to prevent the default Config object to be initialized before the time and any config override to be ignored. This should also fix the tests, #33 --- platypush/event/hook.py | 3 ++- platypush/event/processor/__init__.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/platypush/event/hook.py b/platypush/event/hook.py index ed04ab43..82d252ee 100644 --- a/platypush/event/hook.py +++ b/platypush/event/hook.py @@ -69,7 +69,8 @@ class EventAction(Request): """ Event hook action class. It is a special type of runnable request whose fields can be configured later depending on the event context """ - def __init__(self, target=Config.get('device_id'), action=None, **args): + def __init__(self, target=None, action=None, **args): + if target is None: target=Config.get('device_id') super().__init__(target=target, action=action, **args) diff --git a/platypush/event/processor/__init__.py b/platypush/event/processor/__init__.py index f2254c9e..06ce12e6 100644 --- a/platypush/event/processor/__init__.py +++ b/platypush/event/processor/__init__.py @@ -10,12 +10,14 @@ class EventProcessor(object): """ Event processor class. Checks an event against the configured rules and executes any matching event hooks """ - def __init__(self, hooks=Config.get_event_hooks(), **kwargs): + def __init__(self, hooks=None, **kwargs): """ Params: hooks -- List of event hooks (default: any entry in the config named as event.hook. """ + if hooks is None: hooks = Config.get_event_hooks() + self.hooks = [] for (name, hook) in hooks.items(): h = EventHook.build(name=name, hook=hook)