Commit f3a5bd3b authored by Jean-Paul Smets's avatar Jean-Paul Smets

bugfixes


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1002 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2d3e8a03
......@@ -31,27 +31,30 @@ from Acquisition import aq_base, aq_inner
from cStringIO import StringIO
from email.MIMEBase import MIMEBase
from email import Encoders
from pickle import Pickler, EMPTY_DICT, MARK, DICT
from pickle import Pickler, EMPTY_DICT, MARK, DICT, PyStringMap, DictionaryType
from xml.sax.saxutils import escape, unescape
from zLOG import LOG
class OrderedPickler(Pickler):
dispatch = Pickler.dispatch.copy()
def save_dict(self, obj):
write = self.write
if self.bin:
write(EMPTY_DICT)
else: # proto 0 -- can't use EMPTY_DICT
write(MARK + DICT)
self.memoize(obj)
key_list = obj.keys()
key_list.sort() # Order keys
obj_items = map(lambda x: (x, obj[x]), obj) # XXX Make it lazy in the future
obj_items = map(lambda x: (x, obj[x]), key_list) # XXX Make it lazy in the future
self._batch_setitems(obj_items)
dispatch[DictionaryType] = save_dict
if not PyStringMap is None:
dispatch[PyStringMap] = save_dict
# ERP5 specific pickle function - produces ordered pickles
def dumps(obj, protocol=None, bin=None):
......@@ -59,7 +62,6 @@ def dumps(obj, protocol=None, bin=None):
OrderedPickler(file, protocol, bin).dump(obj)
return file.getvalue()
def Base_asXML(object, ident=0):
"""
Generate an xml text corresponding to the content of this object
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment