<?xml version="1.0"?>
<ZopeData>
  <record id="1" aka="AAAAAAAAAAE=">
    <pickle>
      <tuple>
        <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
        <tuple/>
      </tuple>
    </pickle>
    <pickle>
      <dictionary>
        <item>
            <key> <string>Script_magic</string> </key>
            <value> <int>3</int> </value>
        </item>
        <item>
            <key> <string>_bind_names</string> </key>
            <value>
              <object>
                <klass>
                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
                </klass>
                <tuple/>
                <state>
                  <dictionary>
                    <item>
                        <key> <string>_asgns</string> </key>
                        <value>
                          <dictionary>
                            <item>
                                <key> <string>name_container</string> </key>
                                <value> <string>container</string> </value>
                            </item>
                            <item>
                                <key> <string>name_context</string> </key>
                                <value> <string>context</string> </value>
                            </item>
                            <item>
                                <key> <string>name_m_self</string> </key>
                                <value> <string>script</string> </value>
                            </item>
                            <item>
                                <key> <string>name_subpath</string> </key>
                                <value> <string>traverse_subpath</string> </value>
                            </item>
                          </dictionary>
                        </value>
                    </item>
                  </dictionary>
                </state>
              </object>
            </value>
        </item>
        <item>
            <key> <string>_body</string> </key>
            <value> <string encoding="cdata"><![CDATA[

from Products.ERP5Type.Log import log\n
folder = context\n
\n
# Keep compatibility with tree_id\n
if tree_id_list is not None:\n
  log(\'tree_id\', tree_id)\n
  log(\'tree_id_list\', tree_id_list)\n
  if tree_id is not None:\n
    raise ValueError, "both tree and tree_id_list should not be defined"\n
  tree_id = tree_id_list.pop()\n
\n
activate_kw = {\n
  \'passive_commit\': passive_commit\n
}\n
for key, value in activate_kw.items():\n
  if value is None:\n
    activate_kw.pop(key)\n
\n
\n
# Spawn activities for bundles of content objects.\n
# Bundle size, in object count\n
BUNDLE_ITEM_COUNT = 1000\n
\n
folder_id = folder.getId()\n
def Folder_reindexObjectList(id_list_list):\n
  """\n
    Create an activity calling Folder_reindexObjectList.\n
  """\n
  folder.activate(activity=\'SQLQueue\', priority=object_priority, \n
                  after_tag=object_tag,\n
                  tag=folder_tag, **activate_kw).Folder_reindexObjectList(\n
     None,\n
     id_list_list=id_list_list,\n
     object_priority=object_priority,\n
     object_tag=object_tag,\n
     sql_catalog_id=sql_catalog_id,\n
     passive_commit=passive_commit,\n
     folder_tag=folder_tag,\n
     folder_after_tag=folder_after_tag,\n
  )\n
\n
# HBTree folder\n
id_list = [x for x in folder.objectIds(base_id=tree_id)]\n
# Build a list of list, like this we parse ids only one time,\n
# and then Folder_reinexObjectList will work with one list at\n
# a time and remove it from the list of list\n
# This id_list_list can be quite big and generate quite big\n
# activities, but the effect is limited, because the work is\n
# splitted for each base_id of the HBTree.\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=id_list_list)\n
\n
if tree_id_list is not None:\n
  if len(tree_id_list) > 0:\n
    # Calling again and again the same script allow to decrease the\n
    # number of activities by the same time and increase performance.\n
    folder.activate(activity=\'SQLQueue\', priority=object_priority,\n
      after_tag=tree_after_tag, \n
      tag=tree_tag).Folder_reindexTreeObjectList(\n
        tree_id=None,\n
        tree_id_list=tree_id_list,\n
        folder_tag=folder_tag,\n
        folder_after_tag=folder_after_tag,\n
        object_priority=object_priority,\n
        sql_catalog_id=sql_catalog_id,\n
        object_tag=object_tag,\n
        passive_commit=passive_commit,\n
        tree_after_tag=tree_after_tag,\n
        tree_tag=tree_tag,\n
        )\n


]]></string> </value>
        </item>
        <item>
            <key> <string>_code</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string>tree_id=None, tree_id_list=None, folder_tag=None, folder_after_tag=None, object_tag=None, object_after_tag=None, object_priority=1, sql_catalog_id=None, passive_commit=1, tree_tag=None, tree_after_tag=None</string> </value>
        </item>
        <item>
            <key> <string>errors</string> </key>
            <value>
              <tuple/>
            </value>
        </item>
        <item>
            <key> <string>func_code</string> </key>
            <value>
              <object>
                <klass>
                  <global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
                </klass>
                <tuple/>
                <state>
                  <dictionary>
                    <item>
                        <key> <string>co_argcount</string> </key>
                        <value> <int>11</int> </value>
                    </item>
                    <item>
                        <key> <string>co_varnames</string> </key>
                        <value>
                          <tuple>
                            <string>tree_id</string>
                            <string>tree_id_list</string>
                            <string>folder_tag</string>
                            <string>folder_after_tag</string>
                            <string>object_tag</string>
                            <string>object_after_tag</string>
                            <string>object_priority</string>
                            <string>sql_catalog_id</string>
                            <string>passive_commit</string>
                            <string>tree_tag</string>
                            <string>tree_after_tag</string>
                            <string>Products.ERP5Type.Log</string>
                            <string>log</string>
                            <string>context</string>
                            <string>folder</string>
                            <string>None</string>
                            <string>ValueError</string>
                            <string>_getattr_</string>
                            <string>activate_kw</string>
                            <string>_getiter_</string>
                            <string>key</string>
                            <string>value</string>
                            <string>BUNDLE_ITEM_COUNT</string>
                            <string>folder_id</string>
                            <string>Folder_reindexObjectList</string>
                            <string>append</string>
                            <string>$append0</string>
                            <string>x</string>
                            <string>id_list</string>
                            <string>id_list_list</string>
                            <string>xrange</string>
                            <string>len</string>
                            <string>bundle_index</string>
                            <string>_getitem_</string>
                            <string>remaining_object_id_count</string>
                          </tuple>
                        </value>
                    </item>
                  </dictionary>
                </state>
              </object>
            </value>
        </item>
        <item>
            <key> <string>func_defaults</string> </key>
            <value>
              <tuple>
                <none/>
                <none/>
                <none/>
                <none/>
                <none/>
                <none/>
                <int>1</int>
                <none/>
                <int>1</int>
                <none/>
                <none/>
              </tuple>
            </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>Folder_reindexTreeObjectList</string> </value>
        </item>
        <item>
            <key> <string>warnings</string> </key>
            <value>
              <tuple/>
            </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
