diff --git a/platypush/config/__init__.py b/platypush/config/__init__.py index 7f6915931..c6859e02b 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 7ef0cadd3..478b3a64b 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