Show More
@@ -36,13 +36,17 b' class ContainerWidget(DOMWidget):' | |||
|
36 | 36 | """Validate children list. |
|
37 | 37 | |
|
38 | 38 | Makes sure only one instance of any given model can exist in the |
|
39 |
children list. |
|
|
39 | children list. | |
|
40 | An excellent post on uniqifiers is available at | |
|
41 | http://www.peterbe.com/plog/uniqifiers-benchmark | |
|
42 | which provides the inspiration for using this implementation. Below | |
|
43 | I've implemented the `f5` algorithm using Python comprehensions.""" | |
|
40 | 44 | if new is not None and isinstance(new, list): |
|
41 |
|
|
|
42 | for child in new: | |
|
43 | if child not in children: | |
|
44 |
|
|
|
45 | self._children = children | |
|
45 | seen = {} | |
|
46 | def add_item(i): | |
|
47 | seen[i.model_id] = True | |
|
48 | return i | |
|
49 | return [add_item(i) for i in new if not i.model_id in seen] | |
|
46 | 50 | |
|
47 | 51 | |
|
48 | 52 | class PopupWidget(ContainerWidget): |
General Comments 0
You need to be logged in to leave comments.
Login now