<?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[

folder = context\n
\n
activate_kw = {\n
  \'tag\': object_tag,\n
  \'after_tag\': folder_after_tag,\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
# Reindex folder immediately\n
folder.reindexObject(sql_catalog_id=sql_catalog_id)\n
\n
folder_id = folder.getId()\n
if folder_after_tag is None:\n
  folder_after_tag = ()\n
bundle_tag = "%s_bundle_reindex" % folder_id\n
bundle_object_tag = "%s_reindex" % folder_id\n
\n
# Spawn activities for bundles of content objects.\n
# Bundle size, in object count\n
BUNDLE_ITEM_COUNT=1000\n
\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
                  **activate_kw).Folder_reindexObjectList(\n
     id_list=None,\n
     id_list_list=id_list_list,\n
     object_priority=object_priority,\n
     object_tag=object_tag,\n
     object_after_tag=object_after_tag,\n
     folder_tag=bundle_tag,\n
     folder_after_tag=bundle_object_tag,\n
     sql_catalog_id=sql_catalog_id,\n
     passive_commit=passive_commit,\n
  )\n
\n
try:\n
  tree_id_list = folder.getTreeIdList()\n
except (NotImplementedError, AttributeError):\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 if we have too\n
  # much objects (like millions), we should use HBTree Folders, and\n
  # then the work will be splitted\n
  id_list = [x for x in folder.objectIds()]\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
  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
\n
  # Say to Folder_reindexTreeObjectList to call himself again and\n
  # again until all tree_id_list are parsed. Also, make sure that\n
  # the work of the previous Folder_reindexTreeObjectList is completely\n
  # done\n
  tree_after_tag = folder_after_tag + (bundle_tag, bundle_object_tag)\n
  folder.activate(activity=\'SQLQueue\', priority=object_priority, \n
      after_tag=tree_after_tag, tag=tree_tag,\n
      ).Folder_reindexTreeObjectList(\n
    tree_id=None,\n
    tree_id_list=tree_id_list,\n
    folder_tag=bundle_tag,\n
    folder_after_tag=bundle_object_tag,\n
    object_priority=object_priority,\n
    sql_catalog_id=sql_catalog_id,\n
    passive_commit=passive_commit,\n
    object_tag=bundle_object_tag,\n
    tree_after_tag=tree_after_tag,\n
    tree_tag=tree_tag,\n
    )\n
  \n
  # Start an activity wich will wait the end of the module\n
  folder_id_after_tag =  folder_after_tag + (tree_tag, bundle_tag, bundle_object_tag)\n
  id_activate_kw = {}\n
  if object_tag is not None:\n
    id_activate_kw[\'tag\'] = object_tag\n
\n
  folder.activate(activity=\'SQLDict\', priority=object_priority, \n
                  after_tag=folder_id_after_tag, **id_activate_kw).getId()\n


]]></string> </value>
        </item>
        <item>
            <key> <string>_code</string> </key>
            <value>
              <none/>
            </value>
        </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, start_tree=None, stop_tree=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>9</int> </value>
                    </item>
                    <item>
                        <key> <string>co_varnames</string> </key>
                        <value>
                          <tuple>
                            <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>start_tree</string>
                            <string>stop_tree</string>
                            <string>context</string>
                            <string>folder</string>
                            <string>activate_kw</string>
                            <string>_getiter_</string>
                            <string>_getattr_</string>
                            <string>key</string>
                            <string>value</string>
                            <string>None</string>
                            <string>folder_id</string>
                            <string>bundle_tag</string>
                            <string>bundle_object_tag</string>
                            <string>BUNDLE_ITEM_COUNT</string>
                            <string>Folder_reindexObjectList</string>
                            <string>tree_id_list</string>
                            <string>NotImplementedError</string>
                            <string>AttributeError</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>
                            <string>new_tree_id_list</string>
                            <string>tree_id</string>
                            <string>i</string>
                            <string>tree_tag</string>
                            <string>tree_after_tag</string>
                            <string>folder_id_after_tag</string>
                            <string>id_activate_kw</string>
                            <string>_write_</string>
                            <string>_apply_</string>
                          </tuple>
                        </value>
                    </item>
                  </dictionary>
                </state>
              </object>
            </value>
        </item>
        <item>
            <key> <string>func_defaults</string> </key>
            <value>
              <tuple>
                <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_reindexAll</string> </value>
        </item>
        <item>
            <key> <string>warnings</string> </key>
            <value>
              <tuple/>
            </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
