[Zope-CVS] CVS: Products/Ape/lib/apelib/zodb3 - serializers.py:1.11
Shane Hathaway
shane at zope.com
Tue Jun 1 20:49:49 EDT 2004
Update of /cvs-repository/Products/Ape/lib/apelib/zodb3
In directory cvs.zope.org:/tmp/cvs-serv1887/lib/apelib/zodb3
Modified Files:
serializers.py
Log Message:
Encode the remainder pickle as a list to preserve order
=== Products/Ape/lib/apelib/zodb3/serializers.py 1.10 => 1.11 ===
--- Products/Ape/lib/apelib/zodb3/serializers.py:1.10 Fri Mar 26 10:52:49 2004
+++ Products/Ape/lib/apelib/zodb3/serializers.py Tue Jun 1 20:49:47 2004
@@ -113,25 +113,37 @@
others[key] = value
event.ignore(('data', '_container'))
if others:
- s = encode_to_text(dumps(others, 1), others.keys())
+ # Encode as a sorted list to preserve order.
+ others_list = others.items()
+ others_list.sort()
+ s = encode_to_text(dumps(others_list, 1), others.keys())
else:
s = ''
return {'references': refs, 'others': s}
def deserialize(self, event, state):
assert self.can_serialize(event.obj)
- data = {}
+ data_dict = {}
s = state['others']
if s:
s = decode_from_text(s)
if s:
data = loads(s)
- for key, value in data.items():
+ if hasattr(data, 'items'):
+ # Stored as a dictionary
+ data_list = data.items()
+ data_dict = data
+ else:
+ # Stored as a sequence of tuples
+ data_list = data
+ for key, value in data:
+ data_dict[key] = value
+ for key, value in data_list:
event.deserialized(key, value)
for (key, oid, classification) in state['references']:
value = event.resolve(key, oid, classification)
- data[key] = value
- event.obj.__init__(data)
+ data_dict[key] = value
+ event.obj.__init__(data_dict)
class RollCall:
More information about the Zope-CVS
mailing list