1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 """abstract data types with built-in notification support
23 """
24
25 __version__ = "$Rev$"
26
27
29
31 list.__init__(self)
32 self.watch_id = 0
33 self.watch_procs = {}
34
38
42
46
47 - def pop(self, *args):
51
52 - def sort(self, *args, **kwargs):
55
59
61 for proc in self.watch_procs.values():
62 proc(obj)
63
65 self.watch_id += 1
66 self.watch_procs[self.watch_id] = proc
67 return self.watch_id
68
70 del self.watch_procs[proc_id]
71
72
74
76 dict.__init__(self)
77 self.watch_id = 0
78 self.watch_procs = {}
79
83
88
89 - def pop(self, key, *args):
90 if len(args) > 1:
91 raise TypeError('pop expected at most 2 arguments, got %d' %
92 (len(args) + 1))
93 try:
94 val = dict.pop(self, key)
95 except KeyError:
96 if not len(args):
97 raise
98 val = args[0]
99 self.notify_changed((key, val))
100
105
106 - def update(self, *args, **kwargs):
109
111 for proc in self.watch_procs.values():
112 proc(obj)
113
115 self.watch_id += 1
116 self.watch_procs[self.watch_id] = proc
117 return self.watch_id
118
120 del self.watch_procs[proc_id]
121