Commit fa44918d authored by Yusei Tahara's avatar Yusei Tahara

Remove redefined xxxProperty methods and revert to the previous

behavior. When a property is defined by a property sheet with a
specific storage_id, they break accessors of this property when a
value is mapped to it. And then, for example, a value user entered
through matrixbox and a value indexed by catalog becomes
different. This causes a serious problem. Thus, we need this fix.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41691 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8d804d5e
......@@ -29,7 +29,6 @@
import zope.interface
from AccessControl import ClassSecurityInfo
from Acquisition import aq_base
from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5Type.Core.Predicate import Predicate
......@@ -39,10 +38,6 @@ _MARKER = []
class MappedValue(Predicate):
"""
A MappedValue allows to associate a value to a predicate
XXX Why do we redefine xxxProperty methods ?
When a property is defined by a property sheet with a specific storage_id,
they break accessors of this property when a value is mapped to it.
"""
meta_type = 'ERP5 Mapped Value'
portal_type = 'Mapped Value'
......@@ -77,66 +72,6 @@ class MappedValue(Predicate):
return self._baseGetMappedValueBaseCategoryList(d=d)
return self._baseGetMappedValueBaseCategoryList()
security.declareProtected( Permissions.AccessContentsInformation, 'getProperty' )
def getProperty(self, key, d=_MARKER, **kw):
"""
Use local property instead of calling (acquired) accessor
whenever key is provided by the mapped value.
TODO:
- handle list properties (key ends with _list)
- add unit tests
"""
if key in self.getMappedValuePropertyList():
result = getattr(aq_base(self), key, _MARKER)
if result is not _MARKER:
return result
if d is _MARKER:
return Predicate.getProperty(self, key, **kw) # XXX-JPS I would prefer to use always getProperty
# Is there any reason to overload ?
return Predicate.getProperty(self, key, d=d, **kw)
def getPropertyList(self, key, d=None):
"""
Use local property instead of calling (acquired) accessor
whenever key is provided by the mapped value.
TODO:
- add unit tests
"""
if key in self.getMappedValuePropertyList():
result = getattr(aq_base(self), key, _MARKER)
if result is not _MARKER:
return result
if d is None:
return Predicate.getPropertyList(self, key)
return Predicate.getPropertyList(self, key, d=d)
def _setProperty(self, key, value, type=None, **kw):
"""
Use local property instead of calling (acquired) accessor
whenever key is provided by the mapped value.
TODO:
- handle type
- add unit tests
"""
if key in self.getMappedValuePropertyList():
return setattr(self, key, value)
return Predicate._setProperty(self, key, value, type=type, **kw)
# Check is this method should also be overriden
#def _setPropValue(self, key, value, **kw):
def hasProperty(self, key):
"""
Use local property instead of calling (acquired) accessor
whenever key is provided by the mapped value.
"""
if key in self.getMappedValuePropertyList():
return getattr(self, key, _MARKER) is not _MARKER
return Predicate.hasProperty(self, key)
def _edit(self, **kw):
# We must first prepare the mapped value before we do the edit
edit_order = ['mapped_value_property_list',
......
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