From 1f58bb483810dd96c558a505f4313f3c3ef0ba20 Mon Sep 17 00:00:00 2001
From: Nicolas Delaby <nicolas@nexedi.com>
Date: Tue, 14 Oct 2008 13:39:40 +0000
Subject: [PATCH] Set objects inside destination container instead of set them
 on Tool before

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24169 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Tool/ContributionTool.py | 37 +++++++++++----------------
 1 file changed, 15 insertions(+), 22 deletions(-)

diff --git a/product/ERP5/Tool/ContributionTool.py b/product/ERP5/Tool/ContributionTool.py
index b8165fbcff..afc6aab2d1 100644
--- a/product/ERP5/Tool/ContributionTool.py
+++ b/product/ERP5/Tool/ContributionTool.py
@@ -255,35 +255,28 @@ class ContributionTool(BaseTool):
     ob.isIndexable = 0
 
     # Then put the file inside ourselves for a short while
-    BaseTool._setObject(self, object_id, ob)
-    document = BaseTool._getOb(self, object_id)
 
+    if container_path is not None:
+      container = self.getPortalObject().restrictedTraverse(container_path)
+    document = self._setObject(object_id, ob, user_login=user_login, id=id,
+                               container=container,
+                               discover_metadata=discover_metadata,
+                               )
+    document = self._getOb(object_id) # Call _getOb to purge cache
     rewrite_method = document._getTypeBasedMethod('rewriteIngestionData')
     if rewrite_method is not None:
       modified_kw = rewrite_method(**kw.copy())
       if modified_kw is not None:
         kw.update(modified_kw)
 
-    try:
-      # Then edit the document contents (so that upload can happen)
-      if 'set_filename__' in inspect.getargspec(document._edit)[0]:
-        # Only a few classes supports set_filename__.
-        document._edit(set_filename__=0, **kw)
-      else:
-        document._edit(**kw)
-      if url:
-        document.fromURL(url)
-    finally:
-      # Remove the object from ourselves
-      BaseTool._delObject(self, object_id)
-
-    # Move the document to where it belongs
-    if container_path is not None:
-      container = self.getPortalObject().restrictedTraverse(container_path)
-    document = self._setObject(object_id, ob, user_login=user_login, id=id,
-                               container=container, discover_metadata=discover_metadata,
-                               )
-    document = self._getOb(object_id) # Call _getOb to purge cache
+    # Then edit the document contents (so that upload can happen)
+    if 'set_filename__' in inspect.getargspec(document._edit)[0]:
+      # Only a few classes supports set_filename__.
+      document._edit(set_filename__=0, **kw)
+    else:
+      document._edit(**kw)
+    if url:
+      document.fromURL(url)
 
     # Notify workflows
     #document.notifyWorkflowCreated()
-- 
2.30.9