Package mrv :: Module util :: Class Event
[hide private]
[frames] | no frames]

Class Event

source code

object --+
         |
        Event

Descriptor allowing to easily setup callbacks for classes derived from EventSender
Instance Methods [hide private]
 
__call__(self, *args, **kwargs)
Send our event using the given args
source code
 
__get__(self, inst, cls=None)
Always return self, but keep the instance in case we someone wants to send an event.
source code
 
__init__(self, **kwargs)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
__set__(self, inst, eventfunc)
Set a new event to our object
source code
 
_func_to_key(self, eventfunc)
Returns: an eventfunction suitable to be used as key in our instance event set
source code
 
_getFunctionSet(self, inst)
Returns: function set of the given instance containing functions of our event
source code
 
_get_last_instance(self)
Returns: The last instance that retrieved us
source code
 
_key_to_func(self, eventkey)
Returns: event function from the given eventkey as stored in our events set.
source code
 
duplicate(self) source code
 
remove(self, eventfunc)
remove the given function from this event :note: will not raise if eventfunc does not exist
source code
 
send(self, *args, **kwargs)
Send our event using the given args
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  _curSender = None
hash(x)
  _inst_event_attr = '__events__'
  remove_on_error = False
hash(x)
  sender_as_argument = None
hash(x)
  use_weakref = True
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__call__(self, *args, **kwargs)
(Call operator)

source code 
Send our event using the given args
Returns:
False if at least one event call threw an exception, true otherwise
Notes:
  • if an event listener is weak referenced and goes out of scope
  • will catch all event exceptions trown by the methods called

__init__(self, **kwargs)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Parameters:
  • kwargs -
    • weak: if True, default class configuration use_weakref, weak

      references will be created for event handlers, if False it will be strong references

    • remove_failed: if True, defailt False, failed callback handlers

      will be removed silently

    • sender_as_argument - see class member

Overrides: object.__init__

_func_to_key(self, eventfunc)

source code 
Returns:
an eventfunction suitable to be used as key in our instance event set

_getFunctionSet(self, inst)

source code 
Returns:
function set of the given instance containing functions of our event

_get_last_instance(self)

source code 
Returns:
The last instance that retrieved us

_key_to_func(self, eventkey)

source code 
Returns:
event function from the given eventkey as stored in our events set.

Note: this is required as the event might be weakreffed or not

send(self, *args, **kwargs)

source code 
Send our event using the given args
Returns:
False if at least one event call threw an exception, true otherwise
Notes:
  • if an event listener is weak referenced and goes out of scope
  • will catch all event exceptions trown by the methods called