<?xml version="1.0"?>
<ZopeData>
  <record id="1" aka="AAAAAAAAAAE=">
    <pickle>
      <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
    </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[

"""\n
  This is a custom version, because we don\'t want to definitly delete the objects\n
  but only change state to \'deleted\'.\n
  \n
  This script can also include custom deletions, which comes from legacy \n
  implementations and/or garbage left behind from upgrader.\n
"""\n
\n
from Products.CMFActivity.ActiveResult import ActiveResult\n
portal = context.getPortalObject()\n
active_process = portal.restrictedTraverse(active_process)\n
\n
\n
portal_templates = context.getPortalObject().portal_templates\n
delete_list = []\n
bt_list = portal_templates.objectValues()\n
for bt in bt_list:\n
  bt_id = bt.getId()\n
  installation_state = bt.getInstallationState()\n
  if installation_state in (\'replaced\'):\n
    if fixit:\n
      bt.getObject().delete()\n
      summary="%s was deleted." % bt.getRelativeUrl()\n
    else:\n
      summary="%s is going to be deleted." % bt.getRelativeUrl()\n
    active_process.postResult(ActiveResult(\n
         summary=summary,\n
         severity=2,\n
         detail=""))\n
\n
  elif installation_state == \'not_installed\':\n
    title = bt.getTitle()\n
    modification_date = bt.getModificationDate()\n
    for x in bt_list:\n
      if (x.getTitle() == title and\n
          x.getInstallationState() in (\'installed\', \'not_installed\') and\n
          x.getModificationDate() > modification_date):\n
        if fixit:\n
          bt.getObject().delete()\n
          summary="%s was deleted." % bt.getRelativeUrl()\n
        else:\n
          summary="%s is going to be deleted." % bt.getRelativeUrl()\n
        active_process.postResult(ActiveResult(\n
             summary=summary,\n
             severity=2,\n
             detail=""))\n
        break\n
\n
  elif bt.getTitle().startswith("vifib_") and bt.getVersion() == "999": \n
    delete_list.append(bt_id)\n
\n
if len(delete_list):\n
  if fixit:\n
    context.portal_templates.manage_delObjects(delete_list)\n
    summary="The bt5 with the followed ids were deleted forever: %s" % delete_list\n
  else:\n
    summary="The bt5 with the followed ids are going to be deleted forever: %s" % delete_list\n
  active_process.postResult(ActiveResult(\n
     summary=summary,\n
     severity=2,\n
     detail=""))\n


]]></string> </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string>tag, fixit, active_process, **kw</string> </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>TemplateTool_deleteObsoleteTemplateList</string> </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
