[Erp5-report] r10528 - /erp5/trunk/products/ERP5/Tool/TrashTool.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Oct 4 14:29:29 CEST 2006
Author: aurel
Date: Wed Oct 4 14:29:27 2006
New Revision: 10528
URL: http://svn.erp5.org?rev=10528&view=rev
Log:
don't try to backup an already removed object
Modified:
erp5/trunk/products/ERP5/Tool/TrashTool.py
Modified: erp5/trunk/products/ERP5/Tool/TrashTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Tool/TrashTool.py?rev=10528&r1=10527&r2=10528&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Tool/TrashTool.py (original)
+++ erp5/trunk/products/ERP5/Tool/TrashTool.py Wed Oct 4 14:29:27 2006
@@ -77,29 +77,35 @@
# export object
object_path = container_path + [object_id]
obj = self.unrestrictedTraverse(object_path)
- 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))
+ if obj is None:
+ # object doesn't exist any longer
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
if obj is None:
object_path = container_path + [object_id]
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['allowed_content_type_list'] = getattr(obj, 'allowed_content_types', []) or []
subobjects_dict['hidden_content_type_list'] = getattr(obj, 'hidden_content_type_list', []) or []
@@ -127,14 +133,16 @@
else:
object_path = container_path + [object_id]
obj = self.unrestrictedTraverse(object_path)
- for subobject_id in list(obj.objectIds()):
- subobject_path = object_path + [subobject_id]
- subobject = self.unrestrictedTraverse(subobject_path)
- subobject_copy = subobject._p_jar.exportFile(subobject._p_oid)
- subobjects_dict[subobject_id] = subobject_copy
- if save: # remove subobjecs from backup object
- obj.manage_delObjects([subobject_id])
-# LOG('return subobject dict', 0, subobjects_dict)
+ if obj is None:
+ pass
+ else:
+ for subobject_id in list(obj.objectIds()):
+ subobject_path = object_path + [subobject_id]
+ subobject = self.unrestrictedTraverse(subobject_path)
+ subobject_copy = subobject._p_jar.exportFile(subobject._p_oid)
+ subobjects_dict[subobject_id] = subobject_copy
+ if save: # remove subobjecs from backup object
+ obj.manage_delObjects([subobject_id])
return subobjects_dict
def newTrashBin(self, bt_title='trash', bt=None):
More information about the Erp5-report
mailing list