diff --git a/platypush/config/__init__.py b/platypush/config/__init__.py index ad64d5c46d..7f69159314 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( **{ - prefix + name: obj + getattr(obj, 'procedure_name', 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 bf3afc0a06..7ef0cadd32 100644 --- a/platypush/procedure/__init__.py +++ b/platypush/procedure/__init__.py @@ -4,6 +4,7 @@ import re from functools import wraps from queue import LifoQueue +from typing import Optional from ..common import exec_wrapper from ..config import Config @@ -557,18 +558,22 @@ class IfProcedure(Procedure): return response -def procedure(f): - """ - Public decorator to mark a function as a procedure. - """ +def procedure(name: Optional[str] = None): + def func_wrapper(f): + """ + Public decorator to mark a function as a procedure. + """ - f.procedure = True + f.procedure = True + f.procedure_name = name - @wraps(f) - def _execute_procedure(*args, **kwargs): - return exec_wrapper(f, *args, **kwargs) + @wraps(f) + def _execute_procedure(*args, **kwargs): + return exec_wrapper(f, *args, **kwargs) - return _execute_procedure + return _execute_procedure + + return func_wrapper # vim:sw=4:ts=4:et: