Commit ef655d01 authored by Alexandre Boeglin's avatar Alexandre Boeglin

When property A depends on property B, or Property A and B are acquired

ContentProperties, and only one of them is changed, _edit()'s behaviour could
have been unpredictable.

This is fixed by looping once more over unordered and unmodified properties.
Ordered properties (through edit_order) are not affected.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20052 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent aaed70ab
...@@ -1541,33 +1541,42 @@ class Base( CopyContainer, ...@@ -1541,33 +1541,42 @@ class Base( CopyContainer,
modified_property_dict = self._v_modified_property_dict = {} modified_property_dict = self._v_modified_property_dict = {}
key_list = kw.keys() key_list = kw.keys()
ordered_key_list = [k for k in key_list if k not in edit_order] unordered_key_list = [k for k in key_list if k not in edit_order]
for k in edit_order: ordered_key_list = [k for k in edit_order if k in key_list]
if k in key_list: second_try_key_list = []
ordered_key_list.append(k)
def setChangedPropertyList(key_list):
for key in ordered_key_list: not_modified_list = []
# We only change if the value is different for key in key_list:
# This may be very long... # We only change if the value is different
old_value = None # This may be very long...
if not force_update: old_value = None
try: if not force_update:
old_value = self.getProperty(key, evaluate=0) try:
except TypeError: old_value = self.getProperty(key, evaluate=0)
old_value = self.getProperty(key) except TypeError:
old_value = self.getProperty(key)
if old_value != kw[key] or force_update:
# We keep in a thread var the previous values if old_value != kw[key] or force_update:
# this can be useful for interaction workflow to implement lookups # We keep in a thread var the previous values
# XXX If iteraction workflow script is triggered by edit and calls # this can be useful for interaction workflow to implement lookups
# edit itself, this is useless as the dict will be overwritten # XXX If iteraction workflow script is triggered by edit and calls
# If the keep_existing flag is set to 1, we do not update properties which are defined # edit itself, this is useless as the dict will be overwritten
if not keep_existing or not self.hasProperty(key): # If the keep_existing flag is set to 1, we do not update properties which are defined
modified_property_dict[key] = old_value if not keep_existing or not self.hasProperty(key):
if key != 'id': modified_property_dict[key] = old_value
self._setProperty(key, kw[key]) if key != 'id':
else: self._setProperty(key, kw[key])
self.setId(kw['id'], reindex=reindex_object) else:
self.setId(kw['id'], reindex=reindex_object)
else:
not_modified_list.append(key)
return not_modified_list
unmodified_key_list = setChangedPropertyList(unordered_key_list)
setChangedPropertyList(unmodified_key_list)
# edit_order MUST be enforced, and done at the complete end
setChangedPropertyList(ordered_key_list)
if reindex_object: if reindex_object:
# We do not want to reindex the object if nothing is changed # We do not want to reindex the object if nothing is changed
......
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