Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Jérome Perrin
erp5
Commits
c870a036
Commit
c870a036
authored
Mar 19, 2023
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "XMLExportImport: WIP support pickle protocol 3
🚧
"
This reverts commit
03f7c962
.
parent
03f7c962
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
239 deletions
+72
-239
product/ERP5/Document/BusinessTemplate.py
product/ERP5/Document/BusinessTemplate.py
+5
-6
product/ERP5Type/XMLExportImport/__init__.py
product/ERP5Type/XMLExportImport/__init__.py
+13
-27
product/ERP5Type/XMLExportImport/ppml.py
product/ERP5Type/XMLExportImport/ppml.py
+54
-206
No files found.
product/ERP5/Document/BusinessTemplate.py
View file @
c870a036
...
...
@@ -78,7 +78,7 @@ from OFS.Traversable import NotFound
from
OFS
import
SimpleItem
from
OFS.Image
import
Pdata
import
coverage
from
io
import
BytesIO
,
StringIO
from
io
import
BytesIO
from
copy
import
deepcopy
from
zExceptions
import
BadRequest
from
Products.ERP5Type.XMLExportImport
import
exportXML
,
customImporters
...
...
@@ -347,11 +347,10 @@ class BusinessTemplateArchive(object):
try
:
write
=
self
.
_writeFile
except
AttributeError
:
if
hasattr
(
obj
,
'read'
):
if
not
isinstance
(
obj
,
(
bytes
,
str
)
):
obj
.
seek
(
0
)
obj
=
obj
.
read
()
#import pdb; pdb.set_trace()
if
not
isinstance
(
obj
,
bytes
):
elif
not
isinstance
(
obj
,
bytes
):
obj
=
obj
.
encode
(
'utf-8'
)
self
.
revision
.
hash
(
path
,
obj
)
self
.
_writeString
(
obj
,
path
)
...
...
@@ -866,9 +865,9 @@ class ObjectTemplateItem(BaseTemplateItem):
obj
=
self
.
removeProperties
(
obj
,
1
,
keep_workflow_history
=
True
)
transaction
.
savepoint
(
optimistic
=
True
)
f
=
String
IO
()
f
=
Bytes
IO
()
exportXML
(
obj
.
_p_jar
,
obj
.
_p_oid
,
f
)
bta
.
addObject
(
f
.
getvalue
().
encode
()
,
key
,
path
=
path
)
bta
.
addObject
(
f
,
key
,
path
=
path
)
if
catalog_method_template_item
:
# add all datas specific to catalog inside one file
...
...
product/ERP5Type/XMLExportImport/__init__.py
View file @
c870a036
...
...
@@ -48,7 +48,7 @@ from lxml import etree
from
lxml.etree
import
Element
,
SubElement
from
xml_marshaller.xml_marshaller
import
Marshaller
from
OFS.Image
import
Pdata
from
base64
import
standard_b64encode
,
encodebytes
from
base64
import
standard_b64encode
from
hashlib
import
sha1
from
Products.ERP5Type.Utils
import
ensure_list
#from zLOG import LOG
...
...
@@ -223,6 +223,7 @@ def Folder_asXML(object, omit_xml_declaration=True, root=None):
## The code below was initially from OFS.XMLExportImport
from
six
import
string_types
as
basestring
from
base64
import
encodestring
from
ZODB.serialize
import
referencesf
from
ZODB.ExportImport
import
TemporaryFile
,
export_end_marker
from
ZODB.utils
import
p64
...
...
@@ -252,7 +253,7 @@ def reorderPickle(jar, p):
new_oid
=
storage
.
new_oid
):
"Remap a persistent id to an existing ID and create a ghost for it."
print
(
'persistent_load1'
,
ooid
)
if
isinstance
(
ooid
,
tuple
):
ooid
,
klass
=
ooid
else
:
klass
=
None
...
...
@@ -269,43 +270,34 @@ def reorderPickle(jar, p):
unpickler
.
persistent_load
=
persistent_load
newp
=
BytesIO
()
pickler
=
OrderedPickler
(
newp
,
3
)
pickler
=
OrderedPickler
(
newp
,
1
)
pickler
.
persistent_id
=
persistent_id
classdef
=
unpickler
.
load
()
obj
=
unpickler
.
load
()
pickler
.
dump
(
classdef
)
pickler
.
dump
(
obj
)
if
0
:
# debug
debugp
=
BytesIO
()
debugpickler
=
OrderedPickler
(
debugp
,
3
)
debugpickler
.
persistent_id
=
persistent_id
debugpickler
.
dump
(
obj
)
import
pickletools
print
(
debugp
.
getvalue
())
print
(
pickletools
.
dis
(
debugp
.
getvalue
()))
p
=
newp
.
getvalue
()
return
obj
,
p
def
_mapOid
(
id_mapping
,
oid
):
idprefix
=
str
(
u64
(
oid
))
id
=
id_mapping
[
idprefix
]
old_aka
=
encode
bytes
(
oid
)[:
-
1
]
aka
=
encode
bytes
(
p64
(
long_
(
id
)))[:
-
1
]
# Rebuild oid based on mapped id
old_aka
=
encode
string
(
oid
)[:
-
1
]
aka
=
encode
string
(
p64
(
long_
(
id
)))[:
-
1
]
# Rebuild oid based on mapped id
id_mapping
.
setConvertedAka
(
old_aka
,
aka
)
return
idprefix
+
'.'
,
id
,
aka
def
XMLrecord
(
oid
,
plen
,
p
,
id_mapping
):
# Proceed as usual
f
=
BytesIO
(
p
)
u
=
ppml
.
ToXMLUnpickler
(
f
)
q
=
ppml
.
ToXMLUnpickler
f
=
BytesIO
(
p
)
u
=
q
(
f
)
u
.
idprefix
,
id
,
aka
=
_mapOid
(
id_mapping
,
oid
)
p
=
u
.
load
(
id_mapping
=
id_mapping
).
__str__
(
4
)
p
=
u
.
load
(
id_mapping
=
id_mapping
).
__str__
(
4
)
if
f
.
tell
()
<
plen
:
p
=
p
+
u
.
load
(
id_mapping
=
id_mapping
).
__str__
(
4
)
String
=
' <record id="%s" aka="%s">
\
n
%s </record>
\
n
'
%
(
id
,
aka
.
decode
()
,
p
)
String
=
' <record id="%s" aka="%s">
\
n
%s </record>
\
n
'
%
(
id
,
aka
,
p
)
return
String
def
exportXML
(
jar
,
oid
,
file
=
None
):
...
...
@@ -342,21 +334,15 @@ def exportXML(jar, oid, file=None):
# Do real export
if
file
is
None
:
file
=
TemporaryFile
(
mode
=
'w'
)
file
=
TemporaryFile
()
elif
isinstance
(
file
,
basestring
):
file
=
open
(
file
,
'w'
)
file
=
open
(
file
,
'w
+b
'
)
write
=
file
.
write
write
(
'<?xml version="1.0"?>
\
n
<ZopeData>
\
n
'
)
for
oid
in
reordered_oid_list
:
p
=
getReorderedPickle
(
oid
)
write
(
XMLrecord
(
oid
,
len
(
p
),
p
,
id_mapping
))
write
(
'</ZopeData>
\
n
'
)
if
0
:
try
:
print
(
file
.
getvalue
())
except
AttributeError
:
pass
import
pdb
;
pdb
.
set_trace
()
return
file
class
zopedata
:
...
...
product/ERP5Type/XMLExportImport/ppml.py
View file @
c870a036
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment