Commit ba6b2aac authored by Yusei Tahara's avatar Yusei Tahara

Fixed a bug. if field class had original get_value method and it was...

Fixed a bug. if field class had original get_value method and it was registered in ProxyField module, then use it instead of ProxyField's one.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16581 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f45ba7d2
......@@ -3322,4 +3322,6 @@ from Products.ERP5Type.PsycoWrapper import psyco
#psyco.bind(ListBoxWidget.render)
psyco.bind(ListBoxValidator.validate)
# Register get_value
from Products.ERP5Form.ProxyField import registerOriginalGetValueClassAndArgument
registerOriginalGetValueClassAndArgument(ListBox, 'default')
......@@ -488,3 +488,7 @@ class MatrixBox(ZMIField):
from Products.ERP5Type.PsycoWrapper import psyco
psyco.bind(MatrixBoxWidget.render)
psyco.bind(MatrixBoxValidator.validate)
# Register get_value
from Products.ERP5Form.ProxyField import registerOriginalGetValueClassAndArgument
registerOriginalGetValueClassAndArgument(MatrixBox, 'default')
......@@ -789,3 +789,7 @@ class MultiRelationStringField(ZMIField):
else:
result = ZMIField.get_value(self, id, REQUEST=REQUEST, **kw)
return result
# Register get_value
from Products.ERP5Form.ProxyField import registerOriginalGetValueClassAndArgument
registerOriginalGetValueClassAndArgument(MultiRelationStringField, 'items')
......@@ -283,3 +283,8 @@ def generateSubForm(self, value, REQUEST):
if hasattr(self, 'sub_form'):
delattr(self, 'sub_form')
return hash_list
# Register get_value
from Products.ERP5Form.ProxyField import registerOriginalGetValueClassAndArgument
registerOriginalGetValueClassAndArgument(ParallelListField, '*')
......@@ -3212,3 +3212,7 @@ for klass in (PlanningBoxWidget, BasicStructure, BasicGroup,
Info):
InitializeClass(klass)
allow_class(klass)
# Register get_value
from Products.ERP5Form.ProxyField import registerOriginalGetValueClassAndArgument
registerOriginalGetValueClassAndArgument(PlanningBox, 'default')
......@@ -51,7 +51,6 @@ from Acquisition import aq_base, aq_inner, aq_acquire, aq_chain
from Globals import DTMLFile
from Products.Formulator.TALESField import TALESMethod
from Products.ERP5Form.ListBox import ListBox
from Products.ERP5Form.Form import StaticValue, TALESValue, OverrideValue, DefaultValue, EditableValue
_field_value_cache = {}
......@@ -532,11 +531,11 @@ class ProxyField(ZMIField):
try:
template_field = self.getRecursiveTemplateField()
# Old ListBox instance might have default attribute. so we need to check it.
if id=='default' and isinstance(aq_base(template_field), ListBox):
if checkOriginalGetValue(template_field, id):
return self._get_value(id, **kw)
value = self.get_recursive_orig_value(id)
except KeyError:
# For ListBox
# For ListBox and other exceptional fields.
return self._get_value(id, **kw)
field_id = field.id
......@@ -599,3 +598,38 @@ class ProxyField(ZMIField):
if self.aq_parent:
raise KeyError
return getTransactionalVariable(self)[self._getCacheId()].__of__(self.aq_parent)
#
# get_value exception dict
#
_get_value_exception_dict = {}
def registerOriginalGetValueClassAndArgument(class_, argument_name_list=()):
"""
if field class has its own get_value implementation and
must use it rather than ProxyField's one, then register it.
if argument_name_list is '*' , original get_value is
applied for all arguments.
"""
if not isinstance(argument_name_list, (list, tuple)):
argument_name_list = (argument_name_list,)
_get_value_exception_dict[class_] = argument_name_list
def checkOriginalGetValue(instance, argument_name):
"""
if exception data is registered, then return True
"""
class_ = aq_base(instance).__class__
argument_name_list = _get_value_exception_dict.get(class_)
if argument_name_list is None:
return False
if len(argument_name_list)==1 and argument_name_list[0]=='*':
return True
if argument_name in argument_name_list:
return True
return False
......@@ -178,3 +178,7 @@ class RelationStringField(ZMIField):
else:
result = ZMIField.get_value(self, id, REQUEST=REQUEST, **kw)
return result
# Register get_value
from Products.ERP5Form.ProxyField import registerOriginalGetValueClassAndArgument
registerOriginalGetValueClassAndArgument(RelationStringField, 'items')
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