Commit 6979c6d8 authored by Julien Muchembled's avatar Julien Muchembled

Generate Zope2.12-like class representation on xml export of BTrees objects

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@38488 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2cef8616
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
# Make sure the xml export will be ordered # Make sure the xml export will be ordered
import re
from ZODB.utils import u64, p64 from ZODB.utils import u64, p64
from Shared.DC.xml import ppml from Shared.DC.xml import ppml
from base64 import encodestring from base64 import encodestring
...@@ -68,9 +69,11 @@ class OrderedPickler(Pickler): ...@@ -68,9 +69,11 @@ class OrderedPickler(Pickler):
from ExtensionClass import Base from ExtensionClass import Base
Base__getnewargs__ = getattr(Base, '__getnewargs__', None) Base__getnewargs__ = getattr(Base, '__getnewargs__', None)
if Base__getnewargs__ is None: if Base__getnewargs__ is None:
is_old_btree = lambda pickle: None
def maybeSimplifyClass(klass): def maybeSimplifyClass(klass):
return klass return klass
else: else:
is_old_btree = re.compile('cBTrees\\._(..)BTree\n(\\1)BTree\n').match
def maybeSimplifyClass(klass): def maybeSimplifyClass(klass):
if isinstance(klass, tuple): if isinstance(klass, tuple):
pureclass, newargs = klass pureclass, newargs = klass
...@@ -122,6 +125,8 @@ def reorderPickle(jar, p): ...@@ -122,6 +125,8 @@ def reorderPickle(jar, p):
obj = unpickler.load() obj = unpickler.load()
pickler.dump(obj) pickler.dump(obj)
p=newp.getvalue() p=newp.getvalue()
if is_old_btree(p):
p = p.replace('_','',1)
return obj, p return obj, p
def XMLrecord(oid, plen, p, id_mapping): def XMLrecord(oid, plen, p, id_mapping):
......
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