From d1c0286477a5c9d8c9125052d48100d8b064f5f4 Mon Sep 17 00:00:00 2001
From: Julien Muchembled <jm@nexedi.com>
Date: Fri, 15 Oct 2010 08:40:58 +0000
Subject: [PATCH] Fix retrieval of catalog tool for unwrapped objects

This reverts 39157 & 39184 partially.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39215 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/CopySupport.py             | 7 +++++--
 product/ERP5Type/patches/CMFCatalogAware.py | 3 ++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/product/ERP5Type/CopySupport.py b/product/ERP5Type/CopySupport.py
index bfe17056d1..2c3114f35b 100644
--- a/product/ERP5Type/CopySupport.py
+++ b/product/ERP5Type/CopySupport.py
@@ -360,8 +360,11 @@ class CopyContainer:
           Unindex the object from the portal catalog.
       """
       if self.isIndexable:
-        catalog = getattr(self.getPortalObject(), 'portal_catalog', None)
-        if catalog is not None:
+        try:
+          catalog = self.getPortalObject().portal_catalog
+        except AttributeError:
+          pass
+        else:
           # Make sure there is not activity for this object
           self.flushActivity(invoke=0)
           uid = getattr(self,'uid',None)
diff --git a/product/ERP5Type/patches/CMFCatalogAware.py b/product/ERP5Type/patches/CMFCatalogAware.py
index b058220e3f..98d466a6f0 100644
--- a/product/ERP5Type/patches/CMFCatalogAware.py
+++ b/product/ERP5Type/patches/CMFCatalogAware.py
@@ -16,6 +16,7 @@
 
 from Products.CMFCore.CMFCatalogAware import CMFCatalogAware
 from Acquisition import aq_base
+from Products.CMFCore.utils import getToolByName
 
 def reindexObject(self, idxs=[], *args, **kw):
     """
@@ -30,7 +31,7 @@ def reindexObject(self, idxs=[], *args, **kw):
         # Update the modification date.
         if getattr(aq_base(self), 'notifyModified', None) is not None:
             self.notifyModified()
-    catalog = getattr(self.getPortalObject(), 'portal_catalog', None)
+    catalog = getToolByName(self, 'portal_catalog', None)
     if catalog is not None:
         catalog.reindexObject(self, idxs=idxs, *args, **kw)
 
-- 
2.30.9