Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
acf21da9
Commit
acf21da9
authored
Feb 15, 2010
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LP #195761: fixed ZMI XML export / import and restored it to the UI.
parent
df3cc16a
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
774 additions
and
458 deletions
+774
-458
doc/CHANGES.rst
doc/CHANGES.rst
+2
-0
src/OFS/XMLExportImport.py
src/OFS/XMLExportImport.py
+5
-3
src/OFS/dtml/importExport.dtml
src/OFS/dtml/importExport.dtml
+1
-7
src/OFS/tests/export.xml
src/OFS/tests/export.xml
+344
-0
src/OFS/tests/test_XMLExportImport.py
src/OFS/tests/test_XMLExportImport.py
+79
-1
src/Shared/DC/xml/ppml.py
src/Shared/DC/xml/ppml.py
+343
-447
No files found.
doc/CHANGES.rst
View file @
acf21da9
...
@@ -133,6 +133,8 @@ Features Added
...
@@ -133,6 +133,8 @@ Features Added
Bugs
Fixed
Bugs
Fixed
++++++++++
++++++++++
-
LP
#
195761
:
fixed
ZMI
XML
export
/
import
and
restored
it
to
the
UI
.
-
LP
#
491224
:
proper
escaping
of
rendered
error
message
-
LP
#
491224
:
proper
escaping
of
rendered
error
message
-
LP
#
246983
:
Enabled
unicode
conflict
resolution
on
variables
inside
"string:"
-
LP
#
246983
:
Enabled
unicode
conflict
resolution
on
variables
inside
"string:"
...
...
src/OFS/XMLExportImport.py
View file @
acf21da9
...
@@ -14,6 +14,8 @@ from base64 import encodestring
...
@@ -14,6 +14,8 @@ from base64 import encodestring
from
cStringIO
import
StringIO
from
cStringIO
import
StringIO
from
ZODB.serialize
import
referencesf
from
ZODB.serialize
import
referencesf
from
ZODB.ExportImport
import
TemporaryFile
,
export_end_marker
from
ZODB.ExportImport
import
TemporaryFile
,
export_end_marker
from
ZODB.utils
import
p64
from
ZODB.utils
import
u64
from
Shared.DC.xml
import
ppml
from
Shared.DC.xml
import
ppml
...
@@ -23,7 +25,7 @@ def XMLrecord(oid, len, p):
...
@@ -23,7 +25,7 @@ def XMLrecord(oid, len, p):
q
=
ppml
.
ToXMLUnpickler
q
=
ppml
.
ToXMLUnpickler
f
=
StringIO
(
p
)
f
=
StringIO
(
p
)
u
=
q
(
f
)
u
=
q
(
f
)
id
=
ppml
.
u64
(
oid
)
id
=
u64
(
oid
)
aka
=
encodestring
(
oid
)[:
-
1
]
aka
=
encodestring
(
oid
)[:
-
1
]
u
.
idprefix
=
str
(
id
)
+
'.'
u
.
idprefix
=
str
(
id
)
+
'.'
p
=
u
.
load
().
__str__
(
4
)
p
=
u
.
load
().
__str__
(
4
)
...
@@ -93,11 +95,11 @@ def save_record(parser, tag, data):
...
@@ -93,11 +95,11 @@ def save_record(parser, tag, data):
file
.
seek
(
pos
)
file
.
seek
(
pos
)
a
=
data
[
1
]
a
=
data
[
1
]
if
a
.
has_key
(
'id'
):
oid
=
a
[
'id'
]
if
a
.
has_key
(
'id'
):
oid
=
a
[
'id'
]
oid
=
p
pml
.
p
64
(
int
(
oid
))
oid
=
p64
(
int
(
oid
))
v
=
''
v
=
''
for
x
in
data
[
2
:]:
for
x
in
data
[
2
:]:
v
=
v
+
x
v
=
v
+
x
l
=
p
pml
.
p
64
(
len
(
v
))
l
=
p64
(
len
(
v
))
v
=
oid
+
l
+
v
v
=
oid
+
l
+
v
return
v
return
v
...
...
src/OFS/dtml/importExport.dtml
View file @
acf21da9
...
@@ -10,16 +10,12 @@ them to a different Zope installation. You can either choose
...
@@ -10,16 +10,12 @@ them to a different Zope installation. You can either choose
to download the export file to your local machine, or save it
to download the export file to your local machine, or save it
in the "var" directory of your Zope installation
in the "var" directory of your Zope installation
on the server.
on the server.
<!--
<br/>
<br/>
<br/>
<br/>
<b>Note:</b>
<b>Note:</b>
Zope can export/import objects in two dfferent formats: a binary format (called
Zope can export/import objects in two d
i
fferent formats: a binary format (called
ZEXP) and as XML. The ZEXP format is the officially supported export/import
ZEXP) and as XML. The ZEXP format is the officially supported export/import
format for moving data between <u>identical</u> Zope installations (it is not a migration tool).
format for moving data between <u>identical</u> Zope installations (it is not a migration tool).
The XML export/import is unsupported (and possibly broken under certain circumstances) - use it
at your own risk.
-->
</p>
</p>
<form action="manage_exportObject" method="post">
<form action="manage_exportObject" method="post">
...
@@ -54,7 +50,6 @@ at your own risk.
...
@@ -54,7 +50,6 @@ at your own risk.
</div>
</div>
</td>
</td>
</tr>
</tr>
<!--
<tr>
<tr>
<td align="left" valign="top">
<td align="left" valign="top">
...
@@ -69,7 +64,6 @@ at your own risk.
...
@@ -69,7 +64,6 @@ at your own risk.
</div>
</div>
</td>
</td>
</tr>
</tr>
-->
<tr>
<tr>
<td></td>
<td></td>
<td align="left" valign="top">
<td align="left" valign="top">
...
...
src/OFS/tests/export.xml
0 → 100644
View file @
acf21da9
This diff is collapsed.
Click to expand it.
src/OFS/tests/test_XMLExportImport.py
View file @
acf21da9
# -*- coding: iso8859-1 -*-
##############################################################################
##############################################################################
#
#
# Copyright (c) 2006 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2006 Zope Corporation and Contributors. All Rights Reserved.
...
@@ -16,7 +17,15 @@ import tempfile
...
@@ -16,7 +17,15 @@ import tempfile
import
transaction
import
transaction
from
StringIO
import
StringIO
from
StringIO
import
StringIO
_LONG_DTML
=
'
\
n
'
.
join
([(
'<dtml-var foo%d'
%
x
)
for
x
in
xrange
(
1000
)])
try
:
here
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
except
:
here
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
sys
.
argv
[
0
]))
imagedata
=
os
.
path
.
join
(
here
,
'test.gif'
)
xmldata
=
os
.
path
.
join
(
here
,
'export.xml'
)
_LONG_DTML
=
''
.
join
([(
'<dtml-var foo%d'
%
x
)
for
x
in
xrange
(
1000
)])
class
XMLExportImportTests
(
unittest
.
TestCase
):
class
XMLExportImportTests
(
unittest
.
TestCase
):
...
@@ -112,6 +121,75 @@ class XMLExportImportTests(unittest.TestCase):
...
@@ -112,6 +121,75 @@ class XMLExportImportTests(unittest.TestCase):
# the block above.
# the block above.
os
.
remove
(
path
)
os
.
remove
(
path
)
def
test_exportXML
(
self
):
from
OFS.Folder
import
Folder
from
OFS.Image
import
Image
from
OFS.XMLExportImport
import
exportXML
connection
,
app
=
self
.
_makeJarAndRoot
()
data
=
open
(
imagedata
,
'rb'
)
sub
=
Folder
(
'sub'
)
app
.
_setObject
(
'sub'
,
sub
)
img
=
Image
(
'image'
,
''
,
data
,
'image/gif'
)
sub
.
_setObject
(
'image'
,
img
)
img
.
_setProperty
(
'prop1'
,
3.14159265359
,
'float'
)
img
.
_setProperty
(
'prop2'
,
1
,
'int'
)
img
.
_setProperty
(
'prop3'
,
2L
**
31
-
1
,
'long'
)
img
.
_setProperty
(
'prop4'
,
'xxx'
,
'string'
)
img
.
_setProperty
(
'prop5'
,
[
'xxx'
,
'zzz'
],
'lines'
)
img
.
_setProperty
(
'prop6'
,
u'xxx'
,
'unicode'
)
img
.
_setProperty
(
'prop7'
,
[
u'xxx'
,
u'zzz'
],
'ulines'
)
img
.
_setProperty
(
'prop8'
,
'<&>'
,
'string'
)
img
.
_setProperty
(
'prop9'
,
u'<&>'
,
'unicode'
)
img
.
_setProperty
(
'prop10'
,
'<]]>'
,
'string'
)
img
.
_setProperty
(
'prop11'
,
u'<]]>'
,
'unicode'
)
img
.
_setProperty
(
'prop12'
,
u''
,
'unicode'
)
transaction
.
savepoint
(
optimistic
=
True
)
oid
=
sub
.
_p_oid
handle
,
path
=
tempfile
.
mkstemp
(
suffix
=
'.xml'
)
try
:
ostream
=
os
.
fdopen
(
handle
,
'wb'
)
data
=
exportXML
(
connection
,
oid
,
ostream
)
ostream
.
close
()
finally
:
os
.
remove
(
path
)
def
test_importXML
(
self
):
from
OFS.XMLExportImport
import
importXML
connection
,
app
=
self
.
_makeJarAndRoot
()
newobj
=
importXML
(
connection
,
xmldata
)
img
=
newobj
.
_getOb
(
'image'
)
data
=
open
(
imagedata
,
'rb'
).
read
()
self
.
assertEqual
(
img
.
data
,
data
)
self
.
assertEqual
(
repr
(
img
.
getProperty
(
'prop1'
)),
repr
(
3.14159265359
))
self
.
assertEqual
(
repr
(
img
.
getProperty
(
'prop2'
)),
repr
(
1
))
self
.
assertEqual
(
repr
(
img
.
getProperty
(
'prop3'
)),
repr
(
2L
**
31
-
1
))
self
.
assertEqual
(
repr
(
img
.
getProperty
(
'prop4'
)),
repr
(
'xxx'
))
self
.
assertEqual
(
repr
(
img
.
getProperty
(
'prop5'
)),
repr
((
'xxx'
,
'zzz'
)))
self
.
assertEqual
(
repr
(
img
.
getProperty
(
'prop6'
)),
repr
(
u'xxx'
))
self
.
assertEqual
(
repr
(
img
.
getProperty
(
'prop7'
)),
repr
((
u'xxx'
,
u'zzz'
)))
self
.
assertEqual
(
repr
(
img
.
getProperty
(
'prop8'
)),
repr
(
'<&>'
))
self
.
assertEqual
(
repr
(
img
.
getProperty
(
'prop9'
)),
repr
(
u'<&>'
))
self
.
assertEqual
(
repr
(
img
.
getProperty
(
'prop10'
)),
repr
(
'<]]>'
))
self
.
assertEqual
(
repr
(
img
.
getProperty
(
'prop11'
)),
repr
(
u'<]]>'
))
self
.
assertEqual
(
repr
(
img
.
getProperty
(
'prop12'
)),
repr
(
u''
))
def
test_suite
():
def
test_suite
():
return
unittest
.
TestSuite
((
return
unittest
.
TestSuite
((
unittest
.
makeSuite
(
XMLExportImportTests
),
unittest
.
makeSuite
(
XMLExportImportTests
),
...
...
src/Shared/DC/xml/ppml.py
View file @
acf21da9
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