Commit 388e0bcf authored by Ayush Tiwari's avatar Ayush Tiwari

bt5_config: Use zexp while converting and exporting rather than using XML

parent 242fac2e
...@@ -1060,7 +1060,7 @@ class BusinessItem(Implicit, Persistent): ...@@ -1060,7 +1060,7 @@ class BusinessItem(Implicit, Persistent):
transaction.savepoint(optimistic=True) transaction.savepoint(optimistic=True)
f = StringIO() f = StringIO()
XMLExportImport.exportXML(obj._p_jar, obj._p_oid, f) obj._p_jar.exportFile(obj._p_oid, f)
bma.addObject(f, key, path=path) bma.addObject(f, key, path=path)
def importFile(self, bma, parent, **kw): def importFile(self, bma, parent, **kw):
...@@ -1068,9 +1068,16 @@ class BusinessItem(Implicit, Persistent): ...@@ -1068,9 +1068,16 @@ class BusinessItem(Implicit, Persistent):
def _importFile(self, file_name, file_obj, parent): def _importFile(self, file_name, file_obj, parent):
obj_key, file_ext = os.path.splitext(file_name) obj_key, file_ext = os.path.splitext(file_name)
# id() for installing several bt5 in the same transaction # id() for installing several bt5 in the same transaction
transactional_variable_obj_key = "%s-%s" % (id(self), obj_key) transactional_variable_obj_key = "%s-%s" % (id(self), obj_key)
if file_ext != '.xml':
if file_ext == '.zexp':
connection = self.getConnection(parent)
__traceback_info__ = 'Importing %s' % file_name
obj = connection.importFile(file_obj, customImporters=customImporters)
elif file_ext != '.xml':
# For ZODB Components: if .xml have been processed before, set the # For ZODB Components: if .xml have been processed before, set the
# source code property, otherwise store it in a transactional variable # source code property, otherwise store it in a transactional variable
# so that it can be set once the .xml has been processed # so that it can be set once the .xml has been processed
...@@ -1081,15 +1088,7 @@ class BusinessItem(Implicit, Persistent): ...@@ -1081,15 +1088,7 @@ class BusinessItem(Implicit, Persistent):
getTransactionalVariable()[transactional_variable_obj_key] = data getTransactionalVariable()[transactional_variable_obj_key] = data
else: else:
self._restoreSeparatelyExportedProperty(obj, data) self._restoreSeparatelyExportedProperty(obj, data)
else:
connection = self.getConnection(parent)
__traceback_info__ = 'Importing %s' % file_name
if hasattr(cache_database, 'db') and isinstance(file_obj, file):
obj = connection.importFile(self._compileXML(file_obj))
else:
# FIXME: Why not use the importXML function directly? Are there any BT5s
# with actual .zexp files on the wild?
obj = connection.importFile(file_obj, customImporters=customImporters)
self._value = obj self._value = obj
data = getTransactionalVariable().get(transactional_variable_obj_key) data = getTransactionalVariable().get(transactional_variable_obj_key)
...@@ -1210,7 +1209,7 @@ class BusinessManagerArchive(object): ...@@ -1210,7 +1209,7 @@ class BusinessManagerArchive(object):
def __init__(self, path, **kw): def __init__(self, path, **kw):
self.path = path self.path = path
def addObject(self, obj, name, path=None, ext='.xml'): def addObject(self, obj, name, path=None, ext='.zexp'):
if path: if path:
name = posixpath.join(path, name) name = posixpath.join(path, name)
# XXX required due to overuse of os.path # XXX required due to overuse of os.path
......
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