| 190 | | def update(self, other_dict): |
| 191 | | "update() extends rather than replaces existing key lists." |
| 192 | | if isinstance(other_dict, MultiValueDict): |
| 193 | | for key, value_list in other_dict.lists(): |
| 194 | | self.setlistdefault(key, []).extend(value_list) |
| 195 | | else: |
| 196 | | try: |
| 197 | | for key, value in other_dict.items(): |
| 198 | | self.setlistdefault(key, []).append(value) |
| 199 | | except TypeError: |
| 200 | | raise ValueError, "MultiValueDict.update() takes either a MultiValueDict or dictionary" |
| | 190 | def update(self, *args, **kwargs): |
| | 191 | "update() extends rather than replaces existing key lists. also accepts keyword args." |
| | 192 | if len(args) > 1: |
| | 193 | raise TypeError, "update expected at most 1 arguments, got %d", len(args) |
| | 194 | if args: |
| | 195 | other_dict = args[0] |
| | 196 | if isinstance(other_dict, MultiValueDict): |
| | 197 | for key, value_list in other_dict.lists(): |
| | 198 | self.setlistdefault(key, []).extend(value_list) |
| | 199 | else: |
| | 200 | try: |
| | 201 | for key, value in other_dict.items(): |
| | 202 | self.setlistdefault(key, []).append(value) |
| | 203 | except TypeError: |
| | 204 | raise ValueError, "MultiValueDict.update() takes either a MultiValueDict or dictionary" |
| | 205 | for key, value in kwargs.iteritems(): |
| | 206 | self.setlistdefault(key, []).append(value) |