Commit b53880d6 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

rewrite sample script to follow recent changes.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36696 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e48aa3fe
......@@ -54,33 +54,15 @@
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
returns the list of possible values.\n
"""\n
# XXX it does not support multiple tested properties.\n
if configurable.getPortalType() == \'Solver Decision\':\n
solved_property = configurable.getCausalityValue(). \\\n
getTestedProperty()\n
else:\n
solved_property = configurable.getCausalityValue().getCausalityValue(). \\\n
getTestedProperty()\n
This script returns a dictionary of default properties for Unify Solver.\n
\n
value_list = []\n
for movement in configurable.getDeliveryValueList():\n
value = movement.getProperty(solved_property)\n
if value not in value_list:\n
value_list.append(value)\n
simulation_movement_list = movement.getDeliveryRelatedValueList()\n
# if movement here is a delivery, we need to find simulation\n
# movements by its movements.\n
if len(simulation_movement_list) == 0:\n
simulation_movement_list = sum(\n
[x.getDeliveryRelatedValueList() \\\n
for x in configurable.getDeliveryValue().getMovementList()], [])\n
for simulation_movement in simulation_movement_list:\n
value = simulation_movement.getProperty(solved_property)\n
if value not in value_list:\n
value_list.append(value)\n
return {\'value_list\':[(x, str(x)) for x in value_list]}\n
This is a sample implementation that returns the first item in each list.\n
"""\n
value_list_dict = context.UnifySolver_getDefaultConfigurationPropertyListDict()\n
value_dict = {}\n
for property_id, value_list in value_list_dict.items():\n
value_dict[proeprty_id] = value_list[0]\n
return value_dict\n
</string> </value>
</item>
<item>
......@@ -91,7 +73,7 @@ return {\'value_list\':[(x, str(x)) for x in value_list]}\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>configurable</string> </value>
<value> <string></string> </value>
</item>
<item>
<key> <string>errors</string> </key>
......@@ -111,27 +93,22 @@ return {\'value_list\':[(x, str(x)) for x in value_list]}\n
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>1</int> </value>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>configurable</string>
<string>_getattr_</string>
<string>solved_property</string>
<string>value_list</string>
<string>context</string>
<string>value_list_dict</string>
<string>value_dict</string>
<string>_getiter_</string>
<string>movement</string>
<string>value</string>
<string>simulation_movement_list</string>
<string>len</string>
<string>sum</string>
<string>append</string>
<string>$append0</string>
<string>x</string>
<string>simulation_movement</string>
<string>str</string>
<string>property_id</string>
<string>value_list</string>
<string>_getitem_</string>
<string>_write_</string>
<string>proeprty_id</string>
</tuple>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</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>"""\n
This script returns a dictionary of possible values for Unify Solver.\n
"""\n
solver_decision = context.getCausalityValue()\n
tester = solver_decision.getCausalityValue()\n
value_list_dict = {}\n
for property_id in tester.getTestedProperty():\n
value_list = []\n
for simulation_movement in configurable.getDeliveryValueList():\n
movement = simulation_movement.getDeliveryValue()\n
value = movement.getProperty(property_id)\n
if value not in value_list:\n
value_list.append(value)\n
simulation_movement_list = movement.getDeliveryRelatedValueList()\n
value = simulation_movement.getProperty(property_id)\n
if value not in value_list:\n
value_list.append(value)\n
value_list_dict[property_id] = [(x, repr(x)) for x in value_list]\n
return value_list_dict\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>_getattr_</string>
<string>context</string>
<string>solver_decision</string>
<string>tester</string>
<string>value_list_dict</string>
<string>_getiter_</string>
<string>property_id</string>
<string>value_list</string>
<string>configurable</string>
<string>simulation_movement</string>
<string>movement</string>
<string>value</string>
<string>simulation_movement_list</string>
<string>append</string>
<string>$append0</string>
<string>x</string>
<string>repr</string>
<string>_write_</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>UnifySolver_getDefaultConfigurationPropertyListDict</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
119
\ No newline at end of file
120
\ 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