summaryrefslogtreecommitdiff
path: root/django/utils/datastructures.py
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-04-25 07:30:54 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-04-25 07:30:54 +0000
commitaca569804e661725ed38d2bc0a2ccfd165e4bad0 (patch)
tree919b5295290a3d9be507f2eea6e30ba65dff9d0a /django/utils/datastructures.py
parent535535a45e0a5a0d730b217cec1cba75ce18a948 (diff)
downloaddjango-aca569804e661725ed38d2bc0a2ccfd165e4bad0.tar.gz
Fixed #3964 -- Added a custom SortedDict.__repr__ so that the keys are printed
in sorted order. Based on a patch from Forest Bond. git-svn-id: http://code.djangoproject.com/svn/django/trunk@5069 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/utils/datastructures.py')
-rw-r--r--django/utils/datastructures.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py
index 2b19c06dfb..cca30b462d 100644
--- a/django/utils/datastructures.py
+++ b/django/utils/datastructures.py
@@ -99,6 +99,13 @@ class SortedDict(dict):
obj.keyOrder = self.keyOrder
return obj
+ def __repr__(self):
+ """
+ Replaces the normal dict.__repr__ with a version that returns the keys
+ in their sorted order.
+ """
+ return '{%s}' % ', '.join(['%r: %r' % (k, v) for k, v in self.items()])
+
class MultiValueDictKeyError(KeyError):
pass