<?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 NegatedQuery, Query\n
\n
portal = context.getPortalObject()\n
person_uid = portal.ERP5Site_getPropertyFromAuthenticatedMemberPersonValue(\'uid\')\n
person_reference = portal.ERP5Site_getPropertyFromAuthenticatedMemberPersonValue(\'reference\')\n
\n
setup_service = portal.restrictedTraverse(portal.portal_preferences.getPreferredInstanceSetupResource())\n
\n
# XXX Owner column should not be used to fetch the list!\n
# Data model of hosting subscription should be fixed to allow direct query\n
hosting_subscription_list = portal.portal_catalog(\n
  portal_type="Hosting Subscription",\n
  owner=person_reference,\n
  )\n
\n
# Only return ongoing hosting subscription\n
return [x for x in hosting_subscription_list if \\\n
  (len(portal.portal_catalog(\n
    portal_type="Sale Packing List Line",\n
    simulation_state=NegatedQuery(Query(simulation_state="delivered")),\n
    default_resource_uid=setup_service.getUid(),\n
    default_aggregate_uid=x.getUid(),\n
    limit=1,\n
  )) == 1) or \\\n
  (\n
    (len(portal.portal_catalog(\n
     portal_type="Sale Packing List Line",\n
     default_resource_uid=setup_service.getUid(),\n
     default_aggregate_uid=x.getUid(),\n
     limit=1,\n
    )) == 0) and \\\n
    (len(portal.portal_catalog(\n
     portal_type="Sale Order Line",\n
     default_resource_uid=setup_service.getUid(),\n
     simulation_state="cancelled",\n
     default_aggregate_uid=x.getUid(),\n
     limit=1,\n
    )) == 0)\n
  )]\n
</string> </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string>**kw</string> </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>WebSection_getCurrentHostingSubscriptionList</string> </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
