Author: adrian
Date: 2006-08-31 16:51:19 -0500 (Thu, 31 Aug 2006)
New Revision: 3692
Modified:
django/trunk/AUTHORS
django/trunk/django/utils/datastructures.py
Log:
Fixed #2441 -- Improved MultiValueDict.update() to take keyword args, like
Python 2.4 built-in dict. Thanks for the patch, Pete Shinners
Modified: django/trunk/AUTHORS
===================================================================
--- django/trunk/AUTHORS 2006-08-31 21:35:36 UTC (rev 3691)
+++ django/trunk/AUTHORS 2006-08-31 21:51:19 UTC (rev 3692)
@@ -126,6 +126,7 @@
Oliver Rutherfurd <http://rutherfurd.net/>
Ivan Sagalaev (Maniac) <http://www.softwaremaniacs.org/>
David Schein
+ Pete Shinners <[EMAIL PROTECTED]>
sopel
Thomas Steinacher <[EMAIL PROTECTED]>
Radek Švarz <http://www.svarz.cz/translate/>
Modified: django/trunk/django/utils/datastructures.py
===================================================================
--- django/trunk/django/utils/datastructures.py 2006-08-31 21:35:36 UTC (rev
3691)
+++ django/trunk/django/utils/datastructures.py 2006-08-31 21:51:19 UTC (rev
3692)
@@ -187,17 +187,23 @@
"Returns a copy of this object."
return self.__deepcopy__()
- def update(self, other_dict):
- "update() extends rather than replaces existing key lists."
- if isinstance(other_dict, MultiValueDict):
- for key, value_list in other_dict.lists():
- self.setlistdefault(key, []).extend(value_list)
- else:
- try:
- for key, value in other_dict.items():
- self.setlistdefault(key, []).append(value)
- except TypeError:
- raise ValueError, "MultiValueDict.update() takes either a
MultiValueDict or dictionary"
+ def update(self, *args, **kwargs):
+ "update() extends rather than replaces existing key lists. Also
accepts keyword args."
+ if len(args) > 1:
+ raise TypeError, "update expected at most 1 arguments, got %d",
len(args)
+ if args:
+ other_dict = args[0]
+ if isinstance(other_dict, MultiValueDict):
+ for key, value_list in other_dict.lists():
+ self.setlistdefault(key, []).extend(value_list)
+ else:
+ try:
+ for key, value in other_dict.items():
+ self.setlistdefault(key, []).append(value)
+ except TypeError:
+ raise ValueError, "MultiValueDict.update() takes either a
MultiValueDict or dictionary"
+ for key, value in kwargs.iteritems():
+ self.setlistdefault(key, []).append(value)
class DotExpandedDict(dict):
"""
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates
-~----------~----~----~----~------~----~------~--~---