(self, value)
| 2152 | off[0].selected = True |
| 2153 | |
| 2154 | def _multiple_set_value(self, value): |
| 2155 | compat = self._form.backwards_compat |
| 2156 | turn_on = [] # transactional-ish |
| 2157 | turn_off = [item for item in self.items if |
| 2158 | item.selected and (not item.disabled or compat)] |
| 2159 | names = {} |
| 2160 | for nn in value: |
| 2161 | if nn in names.keys(): |
| 2162 | names[nn] += 1 |
| 2163 | else: |
| 2164 | names[nn] = 1 |
| 2165 | for name, count in names.items(): |
| 2166 | on, off = self._get_items(name, count) |
| 2167 | for i in xrange(count): |
| 2168 | if on: |
| 2169 | item = on[0] |
| 2170 | del on[0] |
| 2171 | del turn_off[turn_off.index(item)] |
| 2172 | else: |
| 2173 | item = off[0] |
| 2174 | del off[0] |
| 2175 | turn_on.append(item) |
| 2176 | for item in turn_off: |
| 2177 | item.selected = False |
| 2178 | for item in turn_on: |
| 2179 | item.selected = True |
| 2180 | |
| 2181 | def set_value_by_label(self, value): |
| 2182 | """Set the value of control by item labels. |
no test coverage detected