<?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\n
from Products.ERP5Type.DateUtils import addToDate\n
portal = context.getPortalObject()\n
\n
kw = {}\n
if modification_date is not None:\n
  kw[\'modification_date\'] = Query(modification_date=addToDate(modification_date, to_add={\'hour\': -1}), range="min")\n
remove_hosting_list = []\n
add_kw_list = []\n
start_date_tuple_list = []\n
\n
hosting_kw = kw.copy()\n
\n
hosting_kw[\'default_destination_section_uid\'] = context.getUid()\n
\n
def getWorkflowDate(document, action):\n
  workflow_item_list = portal.portal_workflow.getInfoFor(ob=document, name=\'history\', wf_id=\'instance_slap_interface_workflow\')\n
  for item in workflow_item_list:\n
    if item.get(\'action\') == action:\n
      return item.get(\'time\')\n
  raise ValueError(\'Document %s has no action %s\' % (document.getPath(), action))\n
\n
for hosting_subscription in portal.portal_catalog(\n
  portal_type=\'Hosting Subscription\',\n
  **hosting_kw\n
  ):\n
  add_kw = dict(\n
    title=hosting_subscription.getTitle(),\n
    aggregate=hosting_subscription.getRelativeUrl()\n
  )\n
  hosting_subscription = hosting_subscription.getObject()\n
  add_kw_list.append((add_kw, hosting_subscription.getPath()))\n
  if hosting_subscription.getSlapState() == \'destroy_requested\':\n
    remove_hosting_list.append((hosting_subscription.getRelativeUrl(), hosting_subscription.getPath()))\n
  try:\n
    start_date = getWorkflowDate(hosting_subscription, \'request_instance\')\n
  except ValueError:\n
    pass\n
  else:\n
    start_date_tuple_list.append((hosting_subscription.getRelativeUrl(), start_date, hosting_subscription.getPath()))\n
\n
\n
result = context.Person_updateOpenSaleOrder(src__=src__, remove_hosting_list=remove_hosting_list, add_kw_list=add_kw_list, start_date_tuple_list=start_date_tuple_list, stop_date=stop_date)\n
from pprint import pformat\n
return pformat(result)\n
</string> </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string>src__=0, modification_date=None, tag=None, stop_date=None</string> </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>Person_storeOpenSaleOrderJournal</string> </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
