Commit 25db378d authored by Łukasz Nowak's avatar Łukasz Nowak

Be scalable.

parent d73c755e
<?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>packing_list = context.getParentValue()\n
if packing_list.getPortalObject().portal_workflow.isTransitionPossible(packing_list, \'start\'):\n
packing_list.start()\n
if packing_list.getPortalObject().portal_workflow.isTransitionPossible(packing_list, \'stop\'):\n
packing_list.stop()\n
if packing_list.getPortalObject().portal_workflow.isTransitionPossible(packing_list, \'deliver\'):\n
packing_list.deliver()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PurchasePackingListLine_deliverIfPossible</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -50,7 +50,9 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>packing_list_line = context.Computer_getSoftwareCleanupPackingListLine(state_change)\n
<value> <string>from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery\n
\n
packing_list_line = context.Computer_getSoftwareCleanupPackingListLine(state_change)\n
portal = packing_list_line.getPortalObject()\n
packing_list = packing_list_line.getParentValue()\n
if packing_list.getPortalObject().portal_workflow.isTransitionPossible(packing_list, \'start\'):\n
......@@ -61,19 +63,32 @@ if packing_list.getPortalObject().portal_workflow.isTransitionPossible(packing_l
packing_list.deliver()\n
\n
# cleanup all other deliveries\n
for packing_list_line in context.Computer_getSoftwarePackingListLineList(\n
state_change,\n
service_uid_list=[portal.restrictedTraverse(portal.portal_preferences.getPreferredSoftwareCleanupResource()).getUid(), portal.restrictedTraverse(portal.portal_preferences.getPreferredSoftwareSetupResource()).getUid()],\n
limit=None,\n
state_list=portal.getPortalReservedInventoryStateList() + portal.getPortalTransitInventoryStateList() + (\'stopped\',)\n
):\n
packing_list = packing_list_line.getParentValue()\n
if packing_list.getPortalObject().portal_workflow.isTransitionPossible(packing_list, \'start\'):\n
packing_list.start()\n
if packing_list.getPortalObject().portal_workflow.isTransitionPossible(packing_list, \'stop\'):\n
packing_list.stop()\n
if packing_list.getPortalObject().portal_workflow.isTransitionPossible(packing_list, \'deliver\'):\n
packing_list.deliver()\n
computer = state_change[\'object\']\n
# Get required arguments\n
kwargs = state_change.kwargs\n
software_release_url = state_change.kwargs["software_release_url"]\n
\n
portal = computer.getPortalObject()\n
\n
# Only get one software release\n
software_release_document_result = computer.portal_catalog(\n
portal_type=\'Software Release\', # validation_state=(\'shared\', \'released\', \'published\', \'shared_alive\', \'released_alive\', \'published_alive\'),\n
url_string=software_release_url, limit=2)\n
if len(software_release_document_result) != 1:\n
raise ValueError("No software release found for %s %s" % (computer.getRelativeUrl(), software_release_url))\n
else:\n
software_release_document = software_release_document_result[0]\n
\n
portal.portal_catalog.searchAndActivate(\n
method_id=\'PurchasePackingListLine_deliverIfPossible\',\n
simulation_state=portal.getPortalReservedInventoryStateList() + portal.getPortalTransitInventoryStateList() + (\'stopped\',),\n
default_service_uid=[portal.restrictedTraverse(portal.portal_preferences.getPreferredSoftwareCleanupResource()).getUid(), portal.restrictedTraverse(portal.portal_preferences.getPreferredSoftwareSetupResource()).getUid()],\n
aggregate_relative_url=ComplexQuery(\n
Query(aggregate_relative_url=software_release_document.getRelativeUrl()),\n
Query(aggregate_relative_url=computer.getRelativeUrl()),\n
operator="AND"),\n
\n
)\n
</string> </value>
</item>
<item>
......
681
\ No newline at end of file
682
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment