From dfb0efae9959effe06d44a982a5b9498b601a3ff Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20Calonne?= <aurel@nexedi.com>
Date: Mon, 21 Mar 2011 09:38:16 +0000
Subject: [PATCH] while reindexing a folder if the Archive_test script exists,
 use it

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@44456 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../erp5_core/Folder_reindexAll.xml           | 33 +++++++++++--------
 product/ERP5/bootstrap/erp5_core/bt/revision  |  2 +-
 2 files changed, 21 insertions(+), 14 deletions(-)

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 27188b0cab..d7e659c4a2 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
@@ -92,7 +92,7 @@ def Folder_reindexObjectList(id_list_list):\n
      sql_catalog_id=sql_catalog_id,\n
      passive_commit=passive_commit,\n
   )\n
-\n
+archive_test_script = getattr(context.getPortalObject(), "Archive_test", None)\n
 try:\n
   tree_id_list = folder.getTreeIdList()\n
 except (NotImplementedError, AttributeError):\n
@@ -112,24 +112,31 @@ except (NotImplementedError, AttributeError):\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
-  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
+else:\n
+  if archive_test_script is not None:\n
+    new_tree_id_list = []\n
     for tree_id in tree_id_list:\n
-      if tree_id < stop_tree:\n
+      if folder.Archive_test(tree_id=tree_id, start_tree=start_tree, stop_tree=stop_tree):\n
         new_tree_id_list.append(tree_id)\n
     tree_id_list = new_tree_id_list\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
+\n
   i = 0\n
 \n
   tree_tag = "%s_tree" % folder_id\n
diff --git a/product/ERP5/bootstrap/erp5_core/bt/revision b/product/ERP5/bootstrap/erp5_core/bt/revision
index ca018e214a..69626a66b8 100644
--- a/product/ERP5/bootstrap/erp5_core/bt/revision
+++ b/product/ERP5/bootstrap/erp5_core/bt/revision
@@ -1 +1 @@
-40936
\ No newline at end of file
+40937
\ No newline at end of file
-- 
2.30.9