<?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>from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery\n
\n
catalog = context.getPortalObject().portal_catalog\n
specialise = context.getPortalObject().portal_categories.specialise\n
causality = context.getPortalObject().portal_categories.causality\n
\n
kw = {}\n
kw.update(\n
  portal_type=\'Sale Packing List\',\n
  limit=None\n
)\n
\n
causality_kw = kw.copy()\n
causality_kw.update(\n
  **{\'category.base_category_uid\': causality.getUid()}\n
)\n
\n
specialise_kw = kw.copy()\n
specialise_kw.update(\n
  **{\'category.base_category_uid\': specialise.getUid()}\n
)\n
\n
casuality_list = tuple([q.getUid() for q in catalog(**causality_kw)])\n
specialise_list = tuple([q.getUid() for q in catalog(**specialise_kw)])\n
\n
existing_dict = {}\n
for spl_uid in casuality_list + specialise_list:\n
  existing_dict[spl_uid] = 1\n
\n
\n
# now check, if there is any SPL which are not migrated\n
\n
if len(existing_dict.keys()) != catalog.countResults(**kw)[0][0]:\n
  if len(existing_dict.keys()) == 1:\n
    where_expression_string = \' != %s\' % existing_dict.keys()[0]\n
  else:\n
    where_expression_string = \' NOT IN (%s)\' % \',\'.join([str(q) for q in existing_dict.keys()])\n
  kw.update(where_expression=\'catalog.uid %s\' % where_expression_string)\n
  for q in catalog(**kw ):\n
    specialise = q.SalePackingList_findSpecialiseByHostingSubscription()\n
    if specialise is not None:\n
      q.setSpecialise(specialise)\n
      print \'Packing list %s migrated\' % q.getRelativeUrl()\n
    else:\n
      print \'WARNING: Packing List %s NOT migrated\' % q.getRelativeUrl()\n
\n
return printed\n
</string> </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string></string> </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>VifibUpgrade_manualPackingListMigrationSetSpecialise</string> </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
