Commit 147bdfb2 authored by Tres Seaver's avatar Tres Seaver

LP #195761: fixed ZMI XML export / import and restored it to the UI.

parent d6ac004f
......@@ -20,6 +20,8 @@ Features Added
Bugs Fixed
++++++++++
- LP #195761: fixed ZMI XML export / import and restored it to the UI.
- MailHost should fall back to HELO when EHLO fails.
Zope 2.12.3 (2010/01/12)
......
......@@ -14,6 +14,8 @@ from base64 import encodestring
from cStringIO import StringIO
from ZODB.serialize import referencesf
from ZODB.ExportImport import TemporaryFile, export_end_marker
from ZODB.utils import p64
from ZODB.utils import u64
from Shared.DC.xml import ppml
......@@ -23,7 +25,7 @@ def XMLrecord(oid, len, p):
q=ppml.ToXMLUnpickler
f=StringIO(p)
u=q(f)
id=ppml.u64(oid)
id=u64(oid)
aka=encodestring(oid)[:-1]
u.idprefix=str(id)+'.'
p=u.load().__str__(4)
......@@ -93,11 +95,11 @@ def save_record(parser, tag, data):
file.seek(pos)
a=data[1]
if a.has_key('id'): oid=a['id']
oid=ppml.p64(int(oid))
oid=p64(int(oid))
v=''
for x in data[2:]:
v=v+x
l=ppml.p64(len(v))
l=p64(len(v))
v=oid+l+v
return v
......
......@@ -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
in the "var" directory of your Zope installation
on the server.
<!--
<br/>
<br/>
<b>Note:</b>
Zope can export/import objects in two dfferent formats: a binary format (called
Zope can export/import objects in two different formats: a binary format (called
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).
The XML export/import is unsupported (and possibly broken under certain circumstances) - use it
at your own risk.
-->
</p>
<form action="manage_exportObject" method="post">
......@@ -54,7 +50,6 @@ at your own risk.
</div>
</td>
</tr>
<!--
<tr>
<td align="left" valign="top">
&nbsp;
......@@ -69,7 +64,6 @@ at your own risk.
</div>
</td>
</tr>
-->
<tr>
<td></td>
<td align="left" valign="top">
......
This diff is collapsed.
# -*- coding: iso8859-1 -*-
##############################################################################
#
# Copyright (c) 2006 Zope Corporation and Contributors. All Rights Reserved.
......@@ -16,7 +17,15 @@ import tempfile
import transaction
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):
......@@ -112,6 +121,75 @@ class XMLExportImportTests(unittest.TestCase):
# the block above.
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():
return unittest.TestSuite((
unittest.makeSuite(XMLExportImportTests),
......
This diff is collapsed.
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