Commit 4b6979a2 authored by Aurel's avatar Aurel

don't try to backup an already removed object


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10528 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent cbd6b899
...@@ -77,29 +77,35 @@ class TrashTool(BaseTool): ...@@ -77,29 +77,35 @@ class TrashTool(BaseTool):
# export object # export object
object_path = container_path + [object_id] object_path = container_path + [object_id]
obj = self.unrestrictedTraverse(object_path) obj = self.unrestrictedTraverse(object_path)
copy = obj._p_jar.exportFile(obj._p_oid) if obj is None:
# import object in trash # object doesn't exist any longer
connection = backup_object_container._p_jar
o = backup_object_container
while connection is None:
o = o.aq_parent
connection=o._p_jar
copy.seek(0)
backup = connection.importFile(copy)
backup.isIndexable = 0
try:
backup_object_container._setObject(object_id, backup)
except AttributeError:
# XXX we can go here due to formulator because attribute field_added
# doesn't not exists on parent if it is a Trash Folder and not a Form
# so object is not backup
LOG("Trash Tool backupObject", 100, "Can't backup object %s" %(object_id))
pass pass
else:
copy = obj._p_jar.exportFile(obj._p_oid)
# import object in trash
connection = backup_object_container._p_jar
o = backup_object_container
while connection is None:
o = o.aq_parent
connection=o._p_jar
copy.seek(0)
backup = connection.importFile(copy)
backup.isIndexable = 0
try:
backup_object_container._setObject(object_id, backup)
except AttributeError:
# XXX we can go here due to formulator because attribute field_added
# doesn't not exists on parent if it is a Trash Folder and not a Form
# so object is not backup
LOG("Trash Tool backupObject", 100, "Can't backup object %s" %(object_id))
pass
# in case of portal types, export properties instead of subobjects # in case of portal types, export properties instead of subobjects
if obj is None: if obj is None:
object_path = container_path + [object_id] object_path = container_path + [object_id]
obj = self.unrestrictedTraverse(object_path) obj = self.unrestrictedTraverse(object_path)
if getattr(obj, 'meta_type', None) == 'ERP5 Type Information': if obj is None:
pass
elif getattr(obj, 'meta_type', None) == 'ERP5 Type Information':
subobjects_dict = {} subobjects_dict = {}
subobjects_dict['allowed_content_type_list'] = getattr(obj, 'allowed_content_types', []) or [] subobjects_dict['allowed_content_type_list'] = getattr(obj, 'allowed_content_types', []) or []
subobjects_dict['hidden_content_type_list'] = getattr(obj, 'hidden_content_type_list', []) or [] subobjects_dict['hidden_content_type_list'] = getattr(obj, 'hidden_content_type_list', []) or []
...@@ -127,14 +133,16 @@ class TrashTool(BaseTool): ...@@ -127,14 +133,16 @@ class TrashTool(BaseTool):
else: else:
object_path = container_path + [object_id] object_path = container_path + [object_id]
obj = self.unrestrictedTraverse(object_path) obj = self.unrestrictedTraverse(object_path)
for subobject_id in list(obj.objectIds()): if obj is None:
subobject_path = object_path + [subobject_id] pass
subobject = self.unrestrictedTraverse(subobject_path) else:
subobject_copy = subobject._p_jar.exportFile(subobject._p_oid) for subobject_id in list(obj.objectIds()):
subobjects_dict[subobject_id] = subobject_copy subobject_path = object_path + [subobject_id]
if save: # remove subobjecs from backup object subobject = self.unrestrictedTraverse(subobject_path)
obj.manage_delObjects([subobject_id]) subobject_copy = subobject._p_jar.exportFile(subobject._p_oid)
# LOG('return subobject dict', 0, subobjects_dict) subobjects_dict[subobject_id] = subobject_copy
if save: # remove subobjecs from backup object
obj.manage_delObjects([subobject_id])
return subobjects_dict return subobjects_dict
def newTrashBin(self, bt_title='trash', bt=None): def newTrashBin(self, bt_title='trash', bt=None):
......
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