Commit e55c11ee authored by Yoshinori Okuji's avatar Yoshinori Okuji

_setProperty must return modified objects from a setter. _edit must take this...

_setProperty must return modified objects from a setter. _edit must take this into account, otherwise content property setters do not reindex correct objects.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24163 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent cb7d3c6b
...@@ -1405,13 +1405,11 @@ class Base( CopyContainer, ...@@ -1405,13 +1405,11 @@ class Base( CopyContainer,
# rather than through implicit aquisition # rather than through implicit aquisition
if getattr(aq_self, accessor_name, None) is not None: if getattr(aq_self, accessor_name, None) is not None:
method = getattr(self, accessor_name) method = getattr(self, accessor_name)
method(value, **kw) return method(value, **kw)
return
public_accessor_name = 'set' + UpperCase(key) public_accessor_name = 'set' + UpperCase(key)
if getattr(aq_self, public_accessor_name, None) is not None: if getattr(aq_self, public_accessor_name, None) is not None:
method = getattr(self, public_accessor_name) method = getattr(self, public_accessor_name)
method(value, **kw) return method(value, **kw)
return
# Try to get a portal_type property (Implementation Dependent) # Try to get a portal_type property (Implementation Dependent)
aq_key = self._aq_key() aq_key = self._aq_key()
if not Base.aq_portal_type.has_key(aq_key): if not Base.aq_portal_type.has_key(aq_key):
...@@ -1419,12 +1417,10 @@ class Base( CopyContainer, ...@@ -1419,12 +1417,10 @@ class Base( CopyContainer,
if getattr(Base.aq_portal_type[aq_key], accessor_name, None) is not None: if getattr(Base.aq_portal_type[aq_key], accessor_name, None) is not None:
method = getattr(self, accessor_name) method = getattr(self, accessor_name)
# LOG("Base.py", 0, "method = %s, name = %s" %(method, accessor_name)) # LOG("Base.py", 0, "method = %s, name = %s" %(method, accessor_name))
method(value, **kw) return method(value, **kw)
return
if getattr(Base.aq_portal_type[aq_key], public_accessor_name, None) is not None: if getattr(Base.aq_portal_type[aq_key], public_accessor_name, None) is not None:
method = getattr(self, public_accessor_name) method = getattr(self, public_accessor_name)
method(value, **kw) return method(value, **kw)
return
# Finaly use standard PropertyManager # Finaly use standard PropertyManager
#LOG("Changing attr: ",0, key) #LOG("Changing attr: ",0, key)
# If we are here, this means we do not use a property that # If we are here, this means we do not use a property that
...@@ -1440,6 +1436,7 @@ class Base( CopyContainer, ...@@ -1440,6 +1436,7 @@ class Base( CopyContainer,
#except: #except:
# # This should be removed if we want strict property checking # # This should be removed if we want strict property checking
# setattr(self, key, value) # setattr(self, key, value)
return (self,)
def _setPropValue(self, key, value, **kw): def _setPropValue(self, key, value, **kw):
self._wrapperCheck(value) self._wrapperCheck(value)
...@@ -1562,6 +1559,7 @@ class Base( CopyContainer, ...@@ -1562,6 +1559,7 @@ class Base( CopyContainer,
hasProperty is False will be updated. hasProperty is False will be updated.
""" """
modified_property_dict = self._v_modified_property_dict = {} modified_property_dict = self._v_modified_property_dict = {}
modified_object_set = set()
key_list = kw.keys() key_list = kw.keys()
unordered_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]
...@@ -1609,7 +1607,12 @@ class Base( CopyContainer, ...@@ -1609,7 +1607,12 @@ class Base( CopyContainer,
guarded_getattr(self, accessor_name) guarded_getattr(self, accessor_name)
modified_property_dict[key] = old_value modified_property_dict[key] = old_value
if key != 'id': if key != 'id':
self._setProperty(key, kw[key]) modified_object_list = self._setProperty(key, kw[key])
# BBB: if the setter does not return anything, assume
# that self has been modified.
if modified_object_list is None:
modified_object_list = (self,)
modified_object_set.update(modified_object_list)
else: else:
self.setId(kw['id'], reindex=reindex_object) self.setId(kw['id'], reindex=reindex_object)
else: else:
...@@ -1622,9 +1625,8 @@ class Base( CopyContainer, ...@@ -1622,9 +1625,8 @@ class Base( CopyContainer,
setChangedPropertyList(ordered_key_list) setChangedPropertyList(ordered_key_list)
if reindex_object: if reindex_object:
# We do not want to reindex the object if nothing is changed for o in modified_object_set:
if (modified_property_dict != {}): o.reindexObject(activate_kw=activate_kw)
self.reindexObject(activate_kw=activate_kw)
security.declareProtected( Permissions.ModifyPortalContent, 'setId' ) security.declareProtected( Permissions.ModifyPortalContent, 'setId' )
def setId(self, id, reindex = 1): def setId(self, id, reindex = 1):
......
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