Commit ccc9742e authored by Łukasz Nowak's avatar Łukasz Nowak

Drop not working complex logic.

Key in _local_properties does not have to match key in property sheets. So
just blindly try to migrate everything from _local_properties and *only* from
there.
parent 6a27d2a1
...@@ -82,26 +82,12 @@ class PropertyTypeValidity(Constraint): ...@@ -82,26 +82,12 @@ class PropertyTypeValidity(Constraint):
error_list = [] error_list = []
# For each attribute name, we check type # For each attribute name, we check type
for prop in obj.propertyMap(): for prop in obj.propertyMap():
property_was_local = False
property_id = prop['id'] property_id = prop['id']
if prop.get('multivalued', 0): if prop.get('multivalued', 0):
property_type = 'lines' property_type = 'lines'
else: else:
property_type = prop['type'] property_type = prop['type']
# if this property was a local property and has been later added in a
# property sheet, we want to remove it from _local_properties
if fixit and \
property_id in [x['id'] for x in
getattr(obj, '_local_properties', ())] and \
len([x for x in obj._propertyMap() if x['id'] == property_id]) > 1:
obj._local_properties = tuple([x for x in obj._local_properties
if x['id'] != property_id])
error_list.append(self._generateError(obj,
self._getMessage('message_local_property_migrated'), dict(
property_id=property_id)))
property_was_local = True
if property_type in self._permissive_type_list: if property_type in self._permissive_type_list:
continue continue
wrong_type = 0 wrong_type = 0
...@@ -141,12 +127,22 @@ class PropertyTypeValidity(Constraint): ...@@ -141,12 +127,22 @@ class PropertyTypeValidity(Constraint):
error_list.append(self._generateError(obj, error_list.append(self._generateError(obj,
self._getMessage(error_message), mapping)) self._getMessage(error_message), mapping))
elif fixit and property_was_local: elif fixit and property_id in \
[x['id'] for x in getattr(obj, '_local_properties', ())]:
# if this property was a local property and has been later added in a
# property sheet, we want to remove it from _local_properties
# but as property key in local_properties does not have to match
# property sheet key name, just all properties will be tried to be migrated
obj._local_properties = tuple([x for x in obj._local_properties
if x['id'] != property_id])
oldvalue = getattr(obj, property_id, value) oldvalue = getattr(obj, property_id, value)
if oldvalue != value: if oldvalue != value:
error_list.append(self._generateError(obj,
self._getMessage('message_local_property_modified'), dict(
property_id=property_id, old_value=oldvalue, new_value=value)))
obj.setProperty(property_id, oldvalue) obj.setProperty(property_id, oldvalue)
if property_id not in \
[x['id'] for x in getattr(obj, '_local_properties', ())]:
error_list.append(self._generateError(obj,
self._getMessage('message_local_property_migrated'), dict(
property_id=property_id)))
return error_list return error_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