Commit fc7716b2 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Add __hash__ into CMFCore.Expression.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1845 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent df9a2dd7
...@@ -866,22 +866,22 @@ class OrderedPickler(Pickler): ...@@ -866,22 +866,22 @@ class OrderedPickler(Pickler):
write(MARK + DICT) write(MARK + DICT)
self.memoize(obj) self.memoize(obj)
item_list = obj.items() # New version by JPS for sorting item_list = obj.items() # New version by JPS for sorting
item_list.sort(lambda a, b: cmp(a[0], b[0])) # New version by JPS for sorting item_list.sort(lambda a, b: cmp(a[0], b[0])) # New version by JPS for sorting
self._batch_setitems(item_list.__iter__()) self._batch_setitems(item_list.__iter__())
dispatch[DictionaryType] = save_dict dispatch[DictionaryType] = save_dict
if not PyStringMap is None: if not PyStringMap is None:
dispatch[PyStringMap] = save_dict dispatch[PyStringMap] = save_dict
def reorderPickle(jar, p): def reorderPickle(jar, p):
from ZODB.ExportImport import Ghost, Unpickler, Pickler, StringIO, persistent_id from ZODB.ExportImport import Ghost, Unpickler, Pickler, StringIO, persistent_id
oids = {} oids = {}
storage = jar._storage storage = jar._storage
new_oid = storage.new_oid new_oid = storage.new_oid
store = storage.store store = storage.store
def persistent_load(ooid, def persistent_load(ooid,
Ghost=Ghost, Ghost=Ghost,
oids=oids, wrote_oid=oids.has_key, oids=oids, wrote_oid=oids.has_key,
...@@ -895,13 +895,13 @@ def reorderPickle(jar, p): ...@@ -895,13 +895,13 @@ def reorderPickle(jar, p):
Ghost=Ghost() Ghost=Ghost()
Ghost.oid=ooid Ghost.oid=ooid
return Ghost return Ghost
# Reorder pickle by doing I/O # Reorder pickle by doing I/O
pfile = StringIO(p) pfile = StringIO(p)
unpickler=Unpickler(pfile) unpickler=Unpickler(pfile)
unpickler.persistent_load=persistent_load unpickler.persistent_load=persistent_load
newp=StringIO() newp=StringIO()
pickler=OrderedPickler(newp,1) pickler=OrderedPickler(newp,1)
pickler.persistent_id=persistent_id pickler.persistent_id=persistent_id
...@@ -912,7 +912,7 @@ def reorderPickle(jar, p): ...@@ -912,7 +912,7 @@ def reorderPickle(jar, p):
p=newp.getvalue() p=newp.getvalue()
return obj, p return obj, p
def PatchedXMLrecord(oid, plen, p, id_mapping): def PatchedXMLrecord(oid, plen, p, id_mapping):
# Proceed as usual # Proceed as usual
q=ppml.ToXMLUnpickler q=ppml.ToXMLUnpickler
f=StringIO(p) f=StringIO(p)
...@@ -1555,3 +1555,13 @@ ppml.xmlPickler = xmlPickler ...@@ -1555,3 +1555,13 @@ ppml.xmlPickler = xmlPickler
class Tuple(Sequence): pass class Tuple(Sequence): pass
ppml.Tuple = Tuple ppml.Tuple = Tuple
######################################################################################
# Expression patch
from Products.CMFCore.Expression import Expression
def Expression_hash(self):
return hash(self.text)
Expression.__hash__ = Expression_hash
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