(self, action, event, *args, **kwargs)
Connect an action to an event or a callback method.
Connect an action to an event or a callback method.
Connect an action to an event or a callback method .
def action(self, action, event, *args, **kwargs):
        """Connect an action to an event or a callback method."""
        # first case: event is a function or a method, and directly bind the
        # action to that function
        if not isinstance(event, basestring):
            callback = event
            # we create a custom event
            event = getattr(callback, '__name__', 'CustomEvent%d' % len(self.bindings))
            # we bind the action to that event
            # we also pass the full User Action Parameters object to the
            # callback
            if 'param_getter' not in kwargs:
                kwargs['param_getter'] = lambda p: p
            self.action(action, event, *args, **kwargs)
            # and we bind that event to the specified callback
            self.event(event, callback)
        else:
            args = (action, event) + args
            # self.add_binding(event, method)
            self.bindings.append((args, kwargs))
def action ( self , action , event , * args , * * kwargs ) : # first case: event is a function or a method, and directly bind the # action to that function if not isinstance ( event , basestring ) : callback = event # we create a custom event event = getattr ( callback , '__name__' , 'CustomEvent%d' % len ( self . bindings ) ) # we bind the action to that event # we also pass the full User Action Parameters object to the # callback if 'param_getter' not in kwargs : kwargs [ 'param_getter' ] = lambda p : p self . action ( action , event , * args , * * kwargs ) # and we bind that event to the specified callback self . event ( event , callback ) else : args = ( action , event ) + args # self.add_binding(event, method) self . bindings . append ( ( args , kwargs ) )