From 28f00d2e9979cd9e42e247ec80a8cdef5da7a774 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20Calonne?= <aurel@nexedi.com>
Date: Tue, 13 Nov 2007 16:41:58 +0000
Subject: [PATCH] allow to give start_tree and stop_tree id when reindexing
 HBTree folder in order not to reindex all the module

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17559 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../erp5_core/ERP5Site_reindexAll.xml         | 29 ++++++++++++------
 .../erp5_core/Folder_reindexAll.xml           | 30 +++++++++++++++++--
 2 files changed, 47 insertions(+), 12 deletions(-)

diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Site_reindexAll.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Site_reindexAll.xml
index d15f4163fc..efd10aed38 100644
--- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Site_reindexAll.xml
+++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Site_reindexAll.xml
@@ -85,7 +85,10 @@ if person_module is not None :\n
                                          object_tag=tag,\n
                                          object_priority=higher_priority,\n
                                          sql_catalog_id=sql_catalog_id,\n
-                                         passive_commit=passive_commit)\n
+                                         passive_commit=passive_commit,\n
+                                         start_tree=start_tree,\n
+                                         stop_tree=stop_tree,)\n
+\n
     \n
 print "#### Indexing translations ####"\n
 context.ERP5Site_updateTranslationTable(sql_catalog_id=sql_catalog_id)\n
@@ -107,7 +110,7 @@ context.portal_categories.activate(\n
                                          object_after_tag=object_after_tag,\n
                                          object_priority=higher_priority,\n
                                          sql_catalog_id=sql_catalog_id,\n
-                                         passive_commit=passive_commit)\n
+                                         passive_commit=passive_commit,)\n
 \n
 print "#### Indexing alarms ####"\n
 print "#### Indexing preferences ####"\n
@@ -127,7 +130,7 @@ for folder in [context.portal_alarms, context.portal_preferences]:\n
                                            object_after_tag=object_after_tag,\n
                                            object_priority=object_priority,\n
                                            sql_catalog_id=sql_catalog_id,\n
-                                           passive_commit=passive_commit)\n
+                                           passive_commit=passive_commit,)\n
 \n
 # We index simulation first to make sure we can calculate tests\n
 # (ie. related quantity)\n
@@ -147,7 +150,7 @@ context.portal_simulation.activate(\n
                                          object_after_tag=object_after_tag,\n
                                          object_priority=higher_priority,\n
                                          sql_catalog_id=sql_catalog_id,\n
-                                         passive_commit=passive_commit)\n
+                                         passive_commit=passive_commit,)\n
 \n
 # We index templates secondly\n
 print "#### Indexing templates ####"\n
@@ -180,7 +183,7 @@ for folder in [context.portal_templates, context.portal_trash,\n
                                            object_after_tag=object_after_tag,\n
                                            object_priority=object_priority,\n
                                            sql_catalog_id=sql_catalog_id,\n
-                                           passive_commit=passive_commit)\n
+                                           passive_commit=passive_commit,)\n
 \n
 # Then we index everything except inventories\n
 for folder in portal.objectValues(("ERP5 Folder",)):\n
@@ -196,7 +199,9 @@ for folder in portal.objectValues(("ERP5 Folder",)):\n
                                      object_after_tag=object_after_tag,\n
                                      object_priority=object_priority,\n
                                      sql_catalog_id=sql_catalog_id,\n
-                                     passive_commit=passive_commit)\n
+                                     passive_commit=passive_commit,\n
+                                     start_tree=start_tree,\n
+                                     stop_tree=stop_tree,)\n
 \n
 # Then we index inventories\n
 object_tag = \'inventory\'\n
@@ -214,7 +219,9 @@ for folder in portal.objectValues(("ERP5 Folder",)):\n
                                      object_after_tag=object_after_tag,\n
                                      object_priority=object_priority,\n
                                      sql_catalog_id=sql_catalog_id,\n
-                                     passive_commit=passive_commit)\n
+                                     passive_commit=passive_commit,\n
+                                     start_tree=start_tree,\n
+                                     stop_tree=stop_tree,)\n
 \n
 # start activty from simulation because the erp5site is not an active object\n
 context.portal_simulation.activate(\n
@@ -261,7 +268,7 @@ return printed\n
         </item>
         <item>
             <key> <string>_params</string> </key>
-            <value> <string>sql_catalog_id=None, additional_priority=0, passive_commit=1, clear_catalog=0, final_activity_tag=None</string> </value>
+            <value> <string>sql_catalog_id=None, additional_priority=0, passive_commit=1, clear_catalog=0, final_activity_tag=None, start_tree=None, stop_tree=None</string> </value>
         </item>
         <item>
             <key> <string>errors</string> </key>
@@ -281,7 +288,7 @@ return printed\n
                   <dictionary>
                     <item>
                         <key> <string>co_argcount</string> </key>
-                        <value> <int>5</int> </value>
+                        <value> <int>7</int> </value>
                     </item>
                     <item>
                         <key> <string>co_varnames</string> </key>
@@ -292,6 +299,8 @@ return printed\n
                             <string>passive_commit</string>
                             <string>clear_catalog</string>
                             <string>final_activity_tag</string>
+                            <string>start_tree</string>
+                            <string>stop_tree</string>
                             <string>_print_</string>
                             <string>_print</string>
                             <string>_getattr_</string>
@@ -327,6 +336,8 @@ return printed\n
                 <int>1</int>
                 <int>0</int>
                 <none/>
+                <none/>
+                <none/>
               </tuple>
             </value>
         </item>
diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Folder_reindexAll.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Folder_reindexAll.xml
index 391ea415e8..00bd8ca424 100644
--- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Folder_reindexAll.xml
+++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Folder_reindexAll.xml
@@ -122,11 +122,29 @@ except (NotImplementedError, AttributeError):\n
   id_list_list = []\n
   for bundle_index in xrange(len(id_list) / BUNDLE_ITEM_COUNT):\n
     id_list_list.append(id_list[bundle_index * BUNDLE_ITEM_COUNT:((bundle_index + 1) * BUNDLE_ITEM_COUNT)])\n
+\n
   remaining_object_id_count = len(id_list) % BUNDLE_ITEM_COUNT\n
   if remaining_object_id_count > 0:\n
     id_list_list.append(id_list[-remaining_object_id_count:])\n
   Folder_reindexObjectList(id_list_list)\n
-else:\n
+else:  \n
+  if start_tree is not None:\n
+    new_tree_id_list = []  \n
+    for tree_id in tree_id_list:\n
+      if tree_id >= start_tree:\n
+        new_tree_id_list.append(tree_id)\n
+    tree_id_list = new_tree_id_list\n
+    \n
+  if stop_tree is not None:\n
+    new_tree_id_list = []  \n
+    for tree_id in tree_id_list:\n
+      if tree_id < stop_tree:\n
+        new_tree_id_list.append(tree_id)\n
+    tree_id_list = new_tree_id_list\n
+\n
+  if len(tree_id_list) == 0:\n
+    return\n
+        \n
   i = 0\n
 \n
   tree_tag = "%s_tree" % folder_id\n
@@ -183,7 +201,7 @@ else:\n
         </item>
         <item>
             <key> <string>_params</string> </key>
-            <value> <string>folder_tag=None, folder_after_tag=None, object_tag=None, object_after_tag=None, object_priority=1, sql_catalog_id=None, passive_commit=1</string> </value>
+            <value> <string>folder_tag=None, folder_after_tag=None, object_tag=None, object_after_tag=None, object_priority=1, sql_catalog_id=None, passive_commit=1, start_tree=None, stop_tree=None</string> </value>
         </item>
         <item>
             <key> <string>errors</string> </key>
@@ -203,7 +221,7 @@ else:\n
                   <dictionary>
                     <item>
                         <key> <string>co_argcount</string> </key>
-                        <value> <int>7</int> </value>
+                        <value> <int>9</int> </value>
                     </item>
                     <item>
                         <key> <string>co_varnames</string> </key>
@@ -216,6 +234,8 @@ else:\n
                             <string>object_priority</string>
                             <string>sql_catalog_id</string>
                             <string>passive_commit</string>
+                            <string>start_tree</string>
+                            <string>stop_tree</string>
                             <string>context</string>
                             <string>folder</string>
                             <string>activate_kw</string>
@@ -242,6 +262,8 @@ else:\n
                             <string>bundle_index</string>
                             <string>_getitem_</string>
                             <string>remaining_object_id_count</string>
+                            <string>new_tree_id_list</string>
+                            <string>tree_id</string>
                             <string>i</string>
                             <string>tree_tag</string>
                             <string>tree_after_tag</string>
@@ -268,6 +290,8 @@ else:\n
                 <int>1</int>
                 <none/>
                 <int>1</int>
+                <none/>
+                <none/>
               </tuple>
             </value>
         </item>
-- 
2.30.9