diff --git a/skygear/registry.py b/skygear/registry.py index 2e05bd4..71fda58 100644 --- a/skygear/registry.py +++ b/skygear/registry.py @@ -117,6 +117,9 @@ def register_hook(self, name, func, *args, **kwargs): raise ValueError("trigger is required for hook") kwargs['name'] = name + if 'async_' in kwargs: + kwargs['async'] = kwargs.pop('async_') + if name in self.func_map['hook']: log.warning("Replacing previously registered hook '%s'.", name) diff --git a/skygear/settings/__init__.py b/skygear/settings/__init__.py index 8af9081..33c7754 100644 --- a/skygear/settings/__init__.py +++ b/skygear/settings/__init__.py @@ -104,7 +104,7 @@ def some_lambda_func(): 'message': 'Some message being returned' } - @skygear.after_save('some_record', async=True) + @skygear.after_save('some_record', async_=True) def some_record_after_save(record, original_record, db): return { 'success': True diff --git a/skygear/tests/test_registry.py b/skygear/tests/test_registry.py index b5f6f28..ab5094e 100644 --- a/skygear/tests/test_registry.py +++ b/skygear/tests/test_registry.py @@ -169,6 +169,7 @@ def fn(): kwargs = { 'type': 'note', 'trigger': 'beforeSave', + 'async_': True, } registry = Registry() registry.register_hook('hook_name', fn, **kwargs) @@ -182,6 +183,7 @@ def fn(): assert param_map[0]['name'] == 'hook_name' assert param_map[0]['type'] == 'note' assert param_map[0]['trigger'] == 'beforeSave' + assert param_map[0]['async'] is True def test_register_hook_twice(self): def fn1():