Commit e219c994 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

define setMappedProperty that handles the reverse mapping of mapped property.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33500 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7d5041e8
......@@ -64,3 +64,24 @@ class MappedProperty(XMLObject):
return -1 * getProperty(mapped_property[1:])
else:
return getProperty(mapped_property)
security.declareProtected(Permissions.AccessContentsInformation,
'setMappedProperty')
def setMappedProperty(self, document, property, value):
if property.endswith('_list'):
property = property[:-5]
setProperty = document.setPropertyList
else:
setProperty = document.setProperty
mapping_dict = {}
for x in self.getMappingPropertyList():
from_property, to_property = [x.strip() for x in x.split('|')]
if to_property.startswith('-'):
mapping_dict[to_property[1:]] = '-%s' % from_property
else:
mapping_dict[to_property] = from_property
mapped_property = mapping_dict.get(property, property)
if mapped_property.startswith('-'):
return setProperty(-1 * value)
else:
return setProperty(value)
......@@ -618,3 +618,12 @@ class SimulationMovement(Movement, PropertyRecordableMixin):
return mapping.getMappedProperty(self, property)
else:
return self.getProperty(property)
security.declareProtected(Permissions.ModifyPortalContent,
'setMappedProperty')
def setMappedProperty(self, property, value):
mapping = self.getPropertyMappingValue()
if mapping is not None:
return mapping.setMappedProperty(self, property, value)
else:
return self.setProperty(property, value)
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