diff --git a/platypush/config/__init__.py b/platypush/config/__init__.py index 7f69159314..c6859e02bb 100644 --- a/platypush/config/__init__.py +++ b/platypush/config/__init__.py @@ -355,7 +355,7 @@ class Config: prefix = modname + '.' if prefix is None else prefix self.procedures.update( **{ - getattr(obj, 'procedure_name', f'{prefix}.{name}'): obj + (getattr(obj, 'procedure_name', None) or f'{prefix}{name}'): obj for name, obj in inspect.getmembers(module) if is_functional_procedure(obj) } diff --git a/platypush/procedure/__init__.py b/platypush/procedure/__init__.py index 7ef0cadd32..478b3a64b6 100644 --- a/platypush/procedure/__init__.py +++ b/platypush/procedure/__init__.py @@ -558,7 +558,9 @@ class IfProcedure(Procedure): return response -def procedure(name: Optional[str] = None): +def procedure(name_or_func: Optional[str] = None, *upper_args, **upper_kwargs): + name = name_or_func if isinstance(name_or_func, str) else None + def func_wrapper(f): """ Public decorator to mark a function as a procedure. @@ -569,10 +571,15 @@ def procedure(name: Optional[str] = None): @wraps(f) def _execute_procedure(*args, **kwargs): + args = [*upper_args, *args] + kwargs = {**upper_kwargs, **kwargs} return exec_wrapper(f, *args, **kwargs) return _execute_procedure + if callable(name_or_func): + return func_wrapper(name_or_func) + return func_wrapper