Commit da187a63 authored by Alexandre Boeglin's avatar Alexandre Boeglin

* add edit_order parameter and logic to _edit() (see changelog of r19605)

* _v_accessor_created_object is no longer useful


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19606 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7cc2926b
......@@ -161,7 +161,6 @@ class Setter(Method):
if o is None:
o = instance.newContent(id=self._storage_id,
portal_type=self._portal_type[0])
instance._v_accessor_created_object = 1
if self._reindex:
warnings.warn("The reindexing accessors are deprecated.\n"
"Please use Alias.Reindex instead.",
......
......@@ -227,7 +227,6 @@ class Setter(Method):
assertAttributePortalType(instance, available_id, self._portal_type)
o = instance.newContent(id=available_id,
portal_type=self._portal_type[0])
instance._v_accessor_created_object = 1
if self._reindex:
warnings.warn("The reindexing accessors are deprecated.\n"
"Please use Alias.Reindex instead.",
......
......@@ -1465,7 +1465,7 @@ class Base( CopyContainer,
# Object attributes update method
security.declarePrivate( '_edit' )
def _edit(self, REQUEST=None, force_update=0, reindex_object=0,
keep_existing=0, activate_kw=None, **kw):
keep_existing=0, activate_kw=None, edit_order=[], **kw):
"""
Generic edit Method for all ERP5 object
The purpose of this method is to update attributed, eventually do
......@@ -1483,9 +1483,13 @@ class Base( CopyContainer,
"""
modified_property_dict = self._v_modified_property_dict = {}
def getModifiedPropertyList(self):
my_modified_property_list = []
for key in kw.keys():
key_list = kw.keys()
ordered_key_list = [k for k in key_list if k not in edit_order]
for k in edit_order:
if k in key_list:
ordered_key_list.append(k)
for key in ordered_key_list:
# We only change if the value is different
# This may be very long...
old_value = None
......@@ -1503,26 +1507,10 @@ class Base( CopyContainer,
# If the keep_existing flag is set to 1, we do not update properties which are defined
if not keep_existing or not self.hasProperty(key):
modified_property_dict[key] = old_value
my_modified_property_list.append(key)
return my_modified_property_list
my_modified_property_list = getModifiedPropertyList(self)
# When we get notified by an accessor that it created an object, recheck
# all properties
while 1:
self._v_accessor_created_object = 0
for key in my_modified_property_list:
if key != 'id':
self._setProperty(key, kw[key])
else:
self.setId(kw['id'], reindex=reindex_object)
if self._v_accessor_created_object == 1:
# refresh list of modified properties, and restart the process
my_modified_property_list = getModifiedPropertyList(self)
break
else:
break
if reindex_object:
# 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