2 def callback_method(func
):
3 def notify(self
,*args
,**kwargs
):
4 rv
= func(self
,*args
,**kwargs
)
5 for callback
in self
.callbacks
:
10 #XXX due to lack of proper slice handling, this will *not* work with python < 3.0
11 class NotifyList(list):
12 extend
= callback_method(list.extend
)
13 append
= callback_method(list.append
)
14 remove
= callback_method(list.remove
)
15 pop
= callback_method(list.pop
)
16 __delitem__
= callback_method(list.__delitem
__)
17 __setitem__
= callback_method(list.__setitem
__)
18 __iadd__
= callback_method(list.__iadd
__)
19 __imul__
= callback_method(list.__imul
__)
21 def __getitem__(self
,item
):
22 if isinstance(item
,slice):
23 return self
.__class
__(list.__getitem
__(self
,item
))
25 return list.__getitem
__(self
,item
)
27 def __init__(self
,*args
,callbacks
=[]):
28 list.__init
__(self
,*args
)
29 self
.callbacks
= callbacks