Commit e2bc2abe authored by Julien Muchembled's avatar Julien Muchembled

List setter without 'List' suffix should not split strings

Before, setFoo was equal to setFooList and
  setFoo('ab cd') equivalent to setFooList(('ab', 'cd'))

With this commit, setFoo('ab cd') == setFooList(('ab cd',))

This fixes changing permission on RoleInformation_view form.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@29646 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 585c9c2e
...@@ -99,7 +99,19 @@ class ListSetter(DefaultSetter): ...@@ -99,7 +99,19 @@ class ListSetter(DefaultSetter):
value = map(self._item_cast, value) value = map(self._item_cast, value)
setattr(instance, self._storage_id, tuple(value)) setattr(instance, self._storage_id, tuple(value))
Setter = ListSetter class Setter(DefaultSetter):
def __call__(self, instance, *args, **kw):
value = args[0]
# Modify the property
if value in self._null:
setattr(instance, self._storage_id, ())
elif self._is_tales_type:
setattr(instance, self._storage_id, str(value))
else:
if self._item_cast is not identity:
value = self._item_cast(value)
setattr(instance, self._storage_id, (value,))
class SetSetter(Base.Setter): class SetSetter(Base.Setter):
""" """
......
...@@ -799,8 +799,8 @@ class TestPropertySheet: ...@@ -799,8 +799,8 @@ class TestPropertySheet:
person = module.newContent(portal_type='Person') person = module.newContent(portal_type='Person')
# Do the same tests as in test_11_valueAccessor # Do the same tests as in test_11_valueAccessor
person.setSubject('beta') person.setSubject('beta gamma')
self.assertEquals(person.getSubject(), 'beta') self.assertEquals(person.getSubject(), 'beta gamma')
person.setSubjectList(['alpha', 'alpha']) person.setSubjectList(['alpha', 'alpha'])
self.assertEquals(person.getSubjectList(), ['alpha', 'alpha']) self.assertEquals(person.getSubjectList(), ['alpha', 'alpha'])
self.assertEquals(person.getSubjectSet(), ['alpha']) self.assertEquals(person.getSubjectSet(), ['alpha'])
......
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