From 87b48f7e3db550997d169ebf0ada48eb59fe27e7 Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Tue, 26 Feb 2008 17:08:12 +0000
Subject: [PATCH] Previous use of serialization_tag was not enough to prevent
 indexation concurency problems. Apply the original code. Though it does not
 use a clean way to check document level, it works.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19529 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/Base.py        | 21 ++++++++++++++++++++-
 product/ERP5Type/Core/Folder.py |  2 +-
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/product/ERP5Type/Base.py b/product/ERP5Type/Base.py
index ae1b9f6429..1a9e1f0341 100644
--- a/product/ERP5Type/Base.py
+++ b/product/ERP5Type/Base.py
@@ -2713,12 +2713,31 @@ class Base( CopyContainer,
       self.activate(group_method_id='portal_catalog/catalogObjectList', 
                     alternate_method_id='alternateReindexObject',
                     group_id=group_id,
-                    serialization_tag=self.getPath() + '%',
+                    serialization_tag=self.getRootDocument(),
                     **activate_kw).immediateReindexObject(**kw)
 
   security.declarePublic('recursiveReindexObject')
   recursiveReindexObject = reindexObject
 
+  def getRootDocument(self):
+    result = self.getRootDocumentValue()
+    if result is not None:
+      result = result.getPath()
+    return result
+    
+  def getRootDocumentValue(self):
+    result = None
+    parent_value = self.getParentValue()
+    if parent_value is not None:
+      parent_id = parent_value.getId()
+      if parent_id.endswith('_module') or parent_id.startswith('portal_'):
+        result = self
+      else:
+        getRootDocumentValue = getattr(parent_value, 'getRootDocumentValue', None)
+        if getRootDocumentValue is not None:
+          result = getRootDocumentValue()
+    return result
+
   security.declareProtected( Permissions.AccessContentsInformation, 'getIndexableChildValueList' )
   def getIndexableChildValueList(self):
     """
diff --git a/product/ERP5Type/Core/Folder.py b/product/ERP5Type/Core/Folder.py
index 70d37edae7..d0a0c19375 100644
--- a/product/ERP5Type/Core/Folder.py
+++ b/product/ERP5Type/Core/Folder.py
@@ -1101,7 +1101,7 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn,
                     expand_method_id='getIndexableChildValueList',
                     alternate_method_id='alternateReindexObject',
                     group_id=group_id,
-                    serialization_tag=self.getPath() + '%',
+                    serialization_tag=self.getRootDocument(),
                     **activate_kw).recursiveImmediateReindexObject(**kw)
 
   security.declareProtected( Permissions.AccessContentsInformation,
-- 
2.30.9