[Zope-CVS] CVS: Products/Ape/lib/apelib/zodb3 - serializers.py:1.12

Shane Hathaway shane at zope.com
Tue Jun 1 22:32:31 EDT 2004


Update of /cvs-repository/Products/Ape/lib/apelib/zodb3
In directory cvs.zope.org:/tmp/cvs-serv28405/lib/apelib/zodb3

Modified Files:
	serializers.py 
Log Message:
Preserve order in the remainder also


=== Products/Ape/lib/apelib/zodb3/serializers.py 1.11 => 1.12 ===
--- Products/Ape/lib/apelib/zodb3/serializers.py:1.11	Tue Jun  1 20:49:47 2004
+++ Products/Ape/lib/apelib/zodb3/serializers.py	Tue Jun  1 22:32:28 2004
@@ -221,14 +221,18 @@
                     unmanaged.append(ob)
             return ref
 
+        # Preserve order to a reasonable extent by storing a list
+        # instead of a dictionary.
+        state_list = state.items()
+        state_list.sort()
         p.persistent_id = persistent_id
         try:
-            p.dump(state)
+            p.dump(state_list)
         except UnpickleableError, exc:
             # Try to reveal which attribute is unpickleable.
             attrname = None
             attrvalue = None
-            for key, value in state.items():
+            for key, value in state_list:
                 del unmanaged[:]
                 outfile.seek(0)
                 outfile.truncate()
@@ -283,6 +287,12 @@
             u = Unpickler(infile)
             u.persistent_load = event.resolve_internal
             s = u.load()
+            if not hasattr(s, 'items'):
+                # Turn the list back into a dictionary
+                s_list = s
+                s = {}
+                for key, value in s_list:
+                    s[key] = value
             event.obj.__dict__.update(s)
             try:
                 unmanaged = u.load()




More information about the Zope-CVS mailing list