def set_action(self, action, *args):
"""Set action and arguments to run in triggered time
:param action: function path as anction
:type action: str
:param args: function arguments
:type args: list or tuple
"""
if isinstance(action, (types.FunctionType, types.MethodType)):
self.action = action
else:
action_module = '.'.join(action.split('.')[:-1])
action_module = importlib.import_module(action_module)
action = action.split('.')[-1]
self.action = getattr(action_module, action)
self.action_args = args
评论列表
文章目录