Author: mtredinnick
Date: 2008-08-24 23:00:15 -0500 (Sun, 24 Aug 2008)
New Revision: 8531
Modified:
django/trunk/AUTHORS
django/trunk/django/utils/datastructures.py
django/trunk/tests/regressiontests/datastructures/tests.py
Log:
Fixed #7496 -- It's now possible to pickle SortedDicts with pickle protocol 2
(used in caching). Thanks, John Huddleston.
Modified: django/trunk/AUTHORS
===================================================================
--- django/trunk/AUTHORS 2008-08-25 03:59:28 UTC (rev 8530)
+++ django/trunk/AUTHORS 2008-08-25 04:00:15 UTC (rev 8531)
@@ -195,6 +195,7 @@
Sung-Jin Hong <[EMAIL PROTECTED]>
Richard House <[EMAIL PROTECTED]>
Robert Rock Howard <http://djangomojo.com/>
+ John Huddleston <[EMAIL PROTECTED]>
Rob Hudson <http://rob.cogit8.org/>
Jason Huggins <http://www.jrandolph.com/blog/>
Hyun Mi Ae
Modified: django/trunk/django/utils/datastructures.py
===================================================================
--- django/trunk/django/utils/datastructures.py 2008-08-25 03:59:28 UTC (rev
8530)
+++ django/trunk/django/utils/datastructures.py 2008-08-25 04:00:15 UTC (rev
8531)
@@ -54,6 +54,11 @@
"""
A dictionary that keeps its keys in the order in which they're inserted.
"""
+ def __new__(cls, *args, **kwargs):
+ instance = super(SortedDict, cls).__new__(cls, *args, **kwargs)
+ instance.keyOrder = []
+ return instance
+
def __init__(self, data=None):
if data is None:
data = {}
Modified: django/trunk/tests/regressiontests/datastructures/tests.py
===================================================================
--- django/trunk/tests/regressiontests/datastructures/tests.py 2008-08-25
03:59:28 UTC (rev 8530)
+++ django/trunk/tests/regressiontests/datastructures/tests.py 2008-08-25
04:00:15 UTC (rev 8531)
@@ -1,6 +1,7 @@
"""
# Tests for stuff in django.utils.datastructures.
+>>> import pickle
>>> from django.utils.datastructures import *
### MergeDict #################################################################
@@ -103,13 +104,16 @@
>>> print repr(d)
{1: 'one', 0: 'zero', 2: 'two'}
+>>> pickle.loads(pickle.dumps(d, 2))
+{1: 'one', 0: 'zero', 2: 'two'}
+
>>> d.clear()
>>> d
{}
>>> d.keyOrder
[]
-### DotExpandedDict
############################################################
+### DotExpandedDict ##########################################################
>>> d = DotExpandedDict({'person.1.firstname': ['Simon'], 'person.1.lastname':
>>> ['Willison'], 'person.2.firstname': ['Adrian'], 'person.2.lastname':
>>> ['Holovaty']})
>>> d['person']['1']['lastname']
@@ -119,7 +123,7 @@
>>> d['person']['2']['firstname']
['Adrian']
-### ImmutableList
################################################################
+### ImmutableList ############################################################
>>> d = ImmutableList(range(10))
>>> d.sort()
Traceback (most recent call last):
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---