From b1e9fa38952959b638633264a43378f013bc97b8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20Calonne?= <aurel@nexedi.com>
Date: Fri, 24 Apr 2009 14:36:18 +0000
Subject: [PATCH] check that newContent exists on current container otherwise
 use zope method to create folder

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26620 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Tool/TrashTool.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/product/ERP5/Tool/TrashTool.py b/product/ERP5/Tool/TrashTool.py
index 827721df73..a62313ff7f 100644
--- a/product/ERP5/Tool/TrashTool.py
+++ b/product/ERP5/Tool/TrashTool.py
@@ -65,9 +65,13 @@ class TrashTool(BaseTool):
         if 'portal' in path:
           path += '_items'
         if path not in backup_object_container.objectIds():
-          backup_object_container = backup_object_container.newContent(portal_type='Trash Folder', id=path,
-                                                                       is_indexable=0)
-          backup_object_container.edit(isHidden=1)
+          if not hasattr(aq_base(backup_object_container), "newContent"):
+            backup_object_container.manage_addFolder(id=path,)
+            backup_object_container = backup_object_container._getOb(path)
+          else:
+            backup_object_container = backup_object_container.newContent(portal_type='Trash Folder', id=path,
+                                                                         is_indexable=0)
+            backup_object_container.edit(isHidden=1)
         else:
           backup_object_container = backup_object_container._getOb(path)
       # backup the object
-- 
2.30.9