<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_callback_for_action(self, action, callback):
 """Adds a callback function to an action The method checks whether both action and callback are valid. If so, the callback is added to the list of functions called when the action is triggered. :param str action: An action like 'add', 'copy', 'info' :param callback: A callback function, which is called when action is triggered. It retrieves the event as parameter :return: True is the parameters are valid and the callback is registered, False else :rtype: bool """

        if hasattr(callback, '__call__'):  # Is the callback really a function?
            if action not in self.__action_to_callbacks:
                self.__action_to_callbacks[action] = []
            self.__action_to_callbacks[action].append(callback)

            controller = None
            try:
                controller = callback.__self__
            except AttributeError:
                try:
                    # Needed when callback was wrapped using functools.partial
                    controller = callback.func.__self__
                except AttributeError:
                    pass

            if controller:
                if controller not in self.__controller_action_callbacks:
                    self.__controller_action_callbacks[controller] = {}
                if action not in self.__controller_action_callbacks[controller]:
                    self.__controller_action_callbacks[controller][action] = []
                self.__controller_action_callbacks[controller][action].append(callback)

            return True