Commit 2db0e92f authored by Jérome Perrin's avatar Jérome Perrin

private accessor now returns the list of modified objects, so that...

private accessor now returns the list of modified objects, so that Alias.Reindex can reindex modified objects.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18784 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent df34859b
......@@ -169,6 +169,7 @@ class Setter(Method):
o.setProperty(self._acquired_property, value, *args, **kw)
else:
o._setProperty(self._acquired_property, value, *args, **kw)
return (o, )
DefaultSetter = Setter
......@@ -54,8 +54,14 @@ class Reindex(Method):
def __call__(self, instance, *args, **kw):
method = getattr(instance, self._accessor_id)
method(*args, **kw)
instance.reindexObject()
modified_object_list = method(*args, **kw)
# private methods can return a list of modified objects that this
# accessor have to reindex
if modified_object_list:
for modified_object in modified_object_list:
modified_object.reindexObject()
else:
instance.reindexObject()
class Dummy(Reindex):
"""
......@@ -79,4 +85,5 @@ class Dummy(Reindex):
def __call__(self, instance, *args, **kw):
method = getattr(instance, self._accessor_id)
method(*args, **kw)
\ No newline at end of file
method(*args, **kw)
......@@ -69,6 +69,7 @@ class Setter(Method):
def __call__(self, instance, *args, **kw):
value = args[0]
modified_object_list = []
if not self._reindex:
# Modify the property
if value in self._null:
......@@ -87,10 +88,13 @@ class Setter(Method):
instance._setObject(self._storage_id, o)
o = getattr(instance, self._storage_id)
o.manage_upload(file = file_upload)
modified_object_list = [o]
else:
LOG('ERP5Type WARNING',0,'%s is not an instance of FileUpload' % str(file_upload))
else:
setattr(instance, self._storage_id, self._cast(args[0]))
modified_object_list.append(instance)
return modified_object_list
else:
# Call the private setter
warnings.warn("The reindexing accessors are deprecated.\n"
......
......@@ -64,6 +64,7 @@ class ListSetter(Method):
"Please use Alias.Reindex instead.",
DeprecationWarning)
instance.reindexObject()
return (instance, )
Setter = ListSetter
......@@ -98,6 +99,7 @@ class DefaultSetter(Method):
"Please use Alias.Reindex instead.",
DeprecationWarning)
instance.reindexObject()
return (instance, )
class SetSetter(Method):
"""
......@@ -142,6 +144,7 @@ class SetSetter(Method):
"Please use Alias.Reindex instead.",
DeprecationWarning)
instance.reindexObject()
return (instance, )
class DefaultGetter(Method):
......
......@@ -209,6 +209,7 @@ class Setter(Method):
# We return the first available object in the list
o = None
available_id = None
modified_object_list = ()
for k in self._storage_id_list:
o = instance._getOb(k, None)
if o is None: available_id = k
......@@ -220,6 +221,7 @@ class Setter(Method):
o.setProperty(self._acquired_property, *args, **kw)
else:
o._setProperty(self._acquired_property, *args, **kw)
modified_object_list = (o, )
if o is None and available_id is not None:
from Products.ERP5Type.Utils import assertAttributePortalType
assertAttributePortalType(instance, available_id, self._portal_type)
......@@ -233,6 +235,8 @@ class Setter(Method):
o.setProperty(self._acquired_property, *args, **kw)
else:
o._setProperty(self._acquired_property, *args, **kw)
modified_object_list = (o, )
return modified_object_list
class ListGetter(Method):
"""
......
......@@ -188,6 +188,7 @@ class SetSetter(Method):
# The list has no default property -> it is empty
new_list_value = []
setattr(instance, self._storage_id, tuple(new_list_value))
return (instance, )
else:
# Call the private setter
warnings.warn("The reindexing accessors are deprecated.\n"
......
......@@ -61,6 +61,7 @@ class SetSetter(Method):
"Please use Alias.Reindex instead.",
DeprecationWarning)
instance.reindexObject()
return (instance, )
psyco.bind(__call__)
......@@ -84,6 +85,7 @@ class ListSetter(SetSetter):
"Please use Alias.Reindex instead.",
DeprecationWarning)
instance.reindexObject()
return (instance, )
psyco.bind(__call__)
......@@ -108,6 +110,7 @@ class DefaultSetter(SetSetter):
"Please use Alias.Reindex instead.",
DeprecationWarning)
instance.reindexObject()
return (instance, )
psyco.bind(__call__)
......@@ -497,6 +500,7 @@ class UidListSetter(UidSetSetter):
"Please use Alias.Reindex instead.",
DeprecationWarning)
instance.reindexObject()
return (instance, )
UidSetter = UidListSetter
......@@ -519,6 +523,7 @@ class UidDefaultSetter(UidSetSetter):
"Please use Alias.Reindex instead.",
DeprecationWarning)
instance.reindexObject()
return (instance, )
class DefaultIdGetter(Method):
"""
......
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