1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 """abstract data types with built-in notification support
19 """
20
21 __version__ = "$Rev$"
22
23
25
27 list.__init__(self)
28 self.watch_id = 0
29 self.watch_procs = {}
30
34
38
42
43 - def pop(self, *args):
47
48 - def sort(self, *args, **kwargs):
51
55
57 for proc in self.watch_procs.values():
58 proc(obj)
59
61 self.watch_id += 1
62 self.watch_procs[self.watch_id] = proc
63 return self.watch_id
64
66 del self.watch_procs[proc_id]
67
68
70
72 dict.__init__(self)
73 self.watch_id = 0
74 self.watch_procs = {}
75
79
84
85 - def pop(self, key, *args):
86 if len(args) > 1:
87 raise TypeError('pop expected at most 2 arguments, got %d' %
88 (len(args) + 1))
89 try:
90 val = dict.pop(self, key)
91 except KeyError:
92 if not len(args):
93 raise
94 val = args[0]
95 self.notify_changed((key, val))
96
101
102 - def update(self, *args, **kwargs):
105
107 for proc in self.watch_procs.values():
108 proc(obj)
109
111 self.watch_id += 1
112 self.watch_procs[self.watch_id] = proc
113 return self.watch_id
114
116 del self.watch_procs[proc_id]
117