Fix thinko and add dire warning

If a mapped property had a '-', it would be called like:

document.setProperty('-price', -20.0)

Also, add a warning about trying to set 'variation_category_list' in a
SimulationMovement with property mapping.
parent 91d9fdd4
......@@ -100,6 +100,10 @@ class MappedProperty(XMLObject):
security.declarePublic('setMappedProperty')
def setMappedProperty(self, document, property, value):
if property.endswith('_list'):
# XXX-Leo: This won't work for 'variation_category_list'
# calling document.setPropertyList('variation_category_list', value)
# breaks with:
# TypeError: A mono valued property must be set with a list of len 1
property = property[:-5]
setProperty = document.setPropertyList
else:
......@@ -107,6 +111,6 @@ class MappedProperty(XMLObject):
mapping_dict = self.getMappingDict(reverse=True)
mapped_property = mapping_dict.get(property, property)
if mapped_property.startswith('-'):
return setProperty(mapped_property, -1 * value)
return setProperty(mapped_property[1:], -1 * value)
else:
return setProperty(mapped_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