Commit 2f1b79bf authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

do not use type based method, but set method id in solver type itself.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36842 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d2e2d15d
...@@ -99,9 +99,9 @@ ...@@ -99,9 +99,9 @@
<string>my_configuration_form_id</string> <string>my_configuration_form_id</string>
<string>my_solver_action_title</string> <string>my_solver_action_title</string>
<string>my_configuration_property_list</string> <string>my_configuration_property_list</string>
<string>my_delivery_solver_list</string>
<string>my_tested_property_list</string> <string>my_tested_property_list</string>
<string>my_automatic_solver</string> <string>my_default_configuration_property_dict_method_id</string>
<string>my_configuration_property_list_dict_method_id</string>
</list> </list>
</value> </value>
</item> </item>
...@@ -109,6 +109,8 @@ ...@@ -109,6 +109,8 @@
<key> <string>right</string> </key> <key> <string>right</string> </key>
<value> <value>
<list> <list>
<string>my_automatic_solver</string>
<string>my_delivery_solver_list</string>
<string>my_conflicting_solver_list</string> <string>my_conflicting_solver_list</string>
<string>my_line_exclusive</string> <string>my_line_exclusive</string>
<string>my_configuration_groupable</string> <string>my_configuration_groupable</string>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>display_width</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_configuration_property_list_dict_method_id</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>display_width</string> </key>
<value> <int>20</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_string_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Configuration Property List Dict Method</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>display_width</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_default_configuration_property_dict_method_id</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>display_width</string> </key>
<value> <int>20</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_string_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Default Configuration Property Dict Method</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
791 792
\ No newline at end of file \ No newline at end of file
...@@ -30,7 +30,6 @@ from AccessControl import ClassSecurityInfo ...@@ -30,7 +30,6 @@ from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, interfaces from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5Type.ERP5Type import ERP5TypeInformation from Products.ERP5Type.ERP5Type import ERP5TypeInformation
from Products.ERP5.Document.Predicate import Predicate from Products.ERP5.Document.Predicate import Predicate
from Products.ERP5Type.Cache import getReadOnlyTransactionCache
class SolverTypeInformation(Predicate, ERP5TypeInformation): class SolverTypeInformation(Predicate, ERP5TypeInformation):
""" """
...@@ -151,8 +150,11 @@ class SolverTypeInformation(Predicate, ERP5TypeInformation): ...@@ -151,8 +150,11 @@ class SolverTypeInformation(Predicate, ERP5TypeInformation):
configurable -- a configurable document (Solver Decision configurable -- a configurable document (Solver Decision
or Target Solver) or Target Solver)
""" """
return self._callTypeBasedMethod( method_id = self.getDefaultConfigurationPropertyDictMethodId()
configurable, 'getDefaultConfigurationPropertyDict') if method_id:
return self._callMethod(configurable, method_id, {})
else:
return {}
def getDefaultConfigurationProperty(self, property, configurable): def getDefaultConfigurationProperty(self, property, configurable):
""" """
...@@ -166,7 +168,7 @@ class SolverTypeInformation(Predicate, ERP5TypeInformation): ...@@ -166,7 +168,7 @@ class SolverTypeInformation(Predicate, ERP5TypeInformation):
""" """
return self.getDefaultConfigurationPropertyDict().get(property, None) return self.getDefaultConfigurationPropertyDict().get(property, None)
def getDefaultConfigurationPropertyListDict(self, configurable): def getConfigurationPropertyListDict(self, configurable):
""" """
Returns a dictionary of possible values for specified Returns a dictionary of possible values for specified
configurable object configurable object
...@@ -175,10 +177,13 @@ class SolverTypeInformation(Predicate, ERP5TypeInformation): ...@@ -175,10 +177,13 @@ class SolverTypeInformation(Predicate, ERP5TypeInformation):
configurable -- a configurable document (Solver Decision configurable -- a configurable document (Solver Decision
or Target Solver) or Target Solver)
""" """
return self._callTypeBasedMethod( method_id = self.getConfigurationPropertyListDictMethodId()
configurable, 'getDefaultConfigurationPropertyListDict') if method_id:
return self._callMethod(configurable, method_id, {})
else:
return {}
def getDefaultConfigurationPropertyList(self, property, configurable): def getConfigurationPropertyList(self, property, configurable):
""" """
Returns a list of possible values for a given property Returns a list of possible values for a given property
(public API) (public API)
...@@ -186,41 +191,27 @@ class SolverTypeInformation(Predicate, ERP5TypeInformation): ...@@ -186,41 +191,27 @@ class SolverTypeInformation(Predicate, ERP5TypeInformation):
configurable -- a configurable document (Solver Decision configurable -- a configurable document (Solver Decision
or Target Solver) or Target Solver)
""" """
return self.getDefaultConfigurationPropertyListDict().get(property, []) return self.getConfigurationPropertyListDict().get(property, [])
def _callTypeBasedMethod(self, configurable, method_id): def _callMethod(self, configurable, method_id, default=None):
# Implemented through type based method # Implemented through type based method
# and using read transaction cache # and using read transaction cache
portal_type = configurable.getPortalType() portal_type = configurable.getPortalType()
if portal_type == 'Solver Decision': if portal_type == 'Solver Decision':
try: try:
solver_portal_type = configurable.getSolverValue().getId() solver_portal_type = configurable.getSolverValue().getId()
solver = None solver = configurable.getParentValue().newContent(
portal_type=solver_portal_type,
temp_object=True,
delivery_list=configurable.getDeliveryList(),
causality_value=configurable)
except AttributeError: except AttributeError:
return {} return default
elif interfaces.ISolver.providedBy(configurable): elif interfaces.ISolver.providedBy(configurable):
solver_portal_type = portal_type solver_portal_type = portal_type
solver = configurable solver = configurable
else: else:
raise NotImplementedError, '%s is not supported for configurable argument' % portal_type raise NotImplementedError, '%s is not supported for configurable argument' % portal_type
cache = getReadOnlyTransactionCache(self) method = getattr(solver, method_id)
if cache is not None:
key = (method_id, solver_portal_type)
try:
return cache[key]()
except KeyError:
pass
if solver is None:
solver = configurable.getParentValue().newContent(
portal_type=solver_portal_type,
temp_object=True,
delivery_list=configurable.getDeliveryList(),
causality_value=configurable)
method = solver._getTypeBasedMethod(
method_id,
fallback_script_id='Solver_%s' % method_id)
if cache is not None:
cache[key] = method
return method() return method()
...@@ -73,6 +73,16 @@ class SolverType: ...@@ -73,6 +73,16 @@ class SolverType:
'mode': 'w', 'mode': 'w',
'label': 'Solve automatically if True' 'label': 'Solve automatically if True'
}, },
{ 'id': 'default_configuration_property_dict_method_id',
'type': 'string',
'mode': 'w',
'description':'the method used to get a dict of default properties.',
},
{ 'id': 'configuration_property_list_dict_method_id',
'type': 'string',
'mode': 'w',
'description':'the method used to get a dict of possible values.',
},
) )
_categories = ('conflicting_solver',) _categories = ('conflicting_solver',)
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