From 233ca03ff27f38f68d15875d74afd6b1b7e14d45 Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Mon, 8 Jan 2007 09:40:52 +0000
Subject: [PATCH] Add a check to determine if the modified SQLCatalog is the
 default one. if not, no need to trigger a reindex. Fix a problem when
 checking for portal_catalog on object which container is at the root of the
 portal (for example, a document contained directly in a module).

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11915 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/BusinessTemplate.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/product/ERP5/Document/BusinessTemplate.py b/product/ERP5/Document/BusinessTemplate.py
index 16c7076a2b..7dce71b52f 100644
--- a/product/ERP5/Document/BusinessTemplate.py
+++ b/product/ERP5/Document/BusinessTemplate.py
@@ -608,7 +608,7 @@ class ObjectTemplateItem(BaseTemplateItem):
               continue
             # If container's container is portal_catalog,
             # then automatically create the container.
-            elif container_path[-2] == 'portal_catalog':
+            elif len(container_path) > 1 and container_path[-2] == 'portal_catalog':
               # The id match, but better double check with the meta type
               # while avoiding the impact of systematic check
               container_container = portal.unrestrictedTraverse(container_path[:-1])
@@ -4061,7 +4061,9 @@ Business Template is a set of definitions, such as skins, portal types and categ
       # update catalog if necessary
       update_catalog=0
       catalog_method = getattr(self, '_catalog_method_item', None)
-      if catalog_method is not None and self.getTemplateFormatVersion() == 1:
+      if catalog_method is not None and self.getTemplateFormatVersion() == 1 \
+        and _getCatalogValue(self) is self.getPortalObject().portal_catalog.getSQLCatalog():
+        # It is needed to update the catalog only if the default SQLCatalog is modified.
         for id in catalog_method._objects.keys():
           if id in object_to_update.keys() or force:
             if not force:
-- 
2.30.9