Code

Ticket #3765: patch.2.diff

File patch.2.diff, 1.7 KB (added by dswistowski@…, 7 years ago)
Line 
1Index: django/db/models/manipulators.py
2===================================================================
3--- django/db/models/manipulators.py    (wersja 5086)
4+++ django/db/models/manipulators.py    (kopia robocza)
5@@ -130,7 +130,7 @@
6                         rel_manager.add(f.rel.to._default_manager.get(pk=n))
7                     # TODO: Add to 'fields_changed'
8 
9-        expanded_data = DotExpandedDict(dict(new_data))
10+        expanded_data = DotExpandedDict(new_data.todict())
11         # Save many-to-one objects. Example: Add the Choice objects for a Poll.
12         for related in self.opts.get_all_related_objects():
13             # Create obj_list, which is a DotExpandedDict such as this:
14Index: django/utils/datastructures.py
15===================================================================
16--- django/utils/datastructures.py      (wersja 5086)
17+++ django/utils/datastructures.py      (kopia robocza)
18@@ -232,6 +232,23 @@
19                     raise ValueError, "MultiValueDict.update() takes either a MultiValueDict or dictionary"
20         for key, value in kwargs.iteritems():
21             self.setlistdefault(key, []).append(value)
22+   
23+    from sys import version_info
24+    major, minor = version_info[0], version_info[1]
25+    if major==2 and minor>4:
26+        def todict(self):
27+            return dict(self.lists())
28+    else:
29+        def todict(self):
30+            return dict(self)       
31+    del(version_info, major, minor)
32+    todict.__doc__ =  """Returns MultiValueDict as dictionary
33+                       
34+                        >>>MultiValueDict(a=[1,2,3]).todict()
35+                        {'a': [1,2,3]}
36+                      """
37+   
38+   
39 
40 class DotExpandedDict(dict):
41     """