Commit b71e5a73 authored by Julien Muchembled's avatar Julien Muchembled

Speed up BT upgrade by exporting temporarily to RAM instead of temporary files

Although this also fixes "too many files" error, the way to upgrade some kinds
of objects should be reviewed in order to avoid such export/import.
parent d3b5cd6f
...@@ -845,30 +845,27 @@ class ObjectTemplateItem(BaseTemplateItem): ...@@ -845,30 +845,27 @@ class ObjectTemplateItem(BaseTemplateItem):
""" """
Backup the object in portal trash if necessery and return its subobjects Backup the object in portal trash if necessery and return its subobjects
""" """
subobjects_dict = {} p = self.getPortalObject()
if trashbin is None: # must return subobjects if trashbin is None: # must return subobjects
object_path = container_path + [object_id] subobject_dict = {}
obj = self.unrestrictedTraverse(object_path) obj = p.unrestrictedTraverse(container_path)[object_id]
for subobject_id in list(obj.objectIds()): for subobject_id in obj.objectIds():
subobject_path = object_path + [subobject_id] subobject = obj[subobject_id]
subobject = self.unrestrictedTraverse(subobject_path) subobject_dict[subobject_id] = subobject._p_jar.exportFile(
subobject_copy = subobject._p_jar.exportFile(subobject._p_oid) subobject._p_oid, StringIO())
subobjects_dict[subobject_id] = subobject_copy return subobject_dict
return subobjects_dict
# XXX btsave is for backward compatibility # XXX btsave is for backward compatibility
if action in ('backup', 'btsave', 'save_and_remove',): if action in ('backup', 'btsave', 'save_and_remove',):
subobjects_dict = self.portal_trash.backupObject(trashbin, save = 1
container_path, object_id,
save=1, **kw)
elif action in ('install', 'remove'): elif action in ('install', 'remove'):
subobjects_dict = self.portal_trash.backupObject(trashbin, save = 0
container_path, object_id,
save=0, **kw)
else: else:
# As the list of available actions is not strictly defined, # As the list of available actions is not strictly defined,
# prevent mistake if an action is not handled # prevent mistake if an action is not handled
raise NotImplementedError, 'Unknown action "%s"' % action raise NotImplementedError, 'Unknown action "%s"' % action
return subobjects_dict return p.portal_trash.backupObject(trashbin, container_path, object_id,
save=save, **kw)
def beforeInstall(self): def beforeInstall(self):
""" """
...@@ -950,6 +947,7 @@ class ObjectTemplateItem(BaseTemplateItem): ...@@ -950,6 +947,7 @@ class ObjectTemplateItem(BaseTemplateItem):
original_reindex_parameters = self.setSafeReindexationMode(context) original_reindex_parameters = self.setSafeReindexationMode(context)
object_key_list = self._getObjectKeyList() object_key_list = self._getObjectKeyList()
for path in object_key_list: for path in object_key_list:
__traceback_info__ = path
# We do not need to perform any backup because the object was # We do not need to perform any backup because the object was
# created during the Business Template installation # created during the Business Template installation
if update_dict.get(path) == 'migrate': if update_dict.get(path) == 'migrate':
......
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