Commit 03c92f96 authored by Jérome Perrin's avatar Jérome Perrin

fix c7cb5665

A set setter keeps the default value, so in a sense the order is preserved.
parent b57a5d20
......@@ -100,7 +100,14 @@ class SetSetter(ListSetter):
"""
if type(value) not in (set, frozenset):
value = frozenset(value)
return ListSetter.__call__(self, instance, value, *args, **kw)
instance._setCategoryMembership(self._key, value,
spec=kw.get('spec',()),
filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()),
base=kw.get('base', 0),
keep_default=1,
checked_permission=kw.get('checked_permission', None))
return (instance, )
class DefaultGetter(BaseGetter):
......
......@@ -700,8 +700,14 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
self.assertEquals(person.getRegionList(), ['alpha', 'beta'])
person.setRegionList(['beta', 'alpha', 'alpha'])
self.assertEquals(person.getRegionList(), ['beta', 'alpha', 'alpha'])
# at this point the person have a default region set to the first item in
# the list.
self.assertEquals(person.getDefaultRegion(), 'beta')
person.setRegionSet(['alpha', 'beta', 'alpha'])
self.assertEquals(sorted(person.getRegionList()), ['alpha', 'beta'])
self.assertEquals(person.getRegionList(), ['beta', 'alpha'])
# calling a set setter did not change the default region
self.assertEquals(person.getDefaultRegion(), 'beta')
person.setDefaultRegion('alpha')
self.assertEquals(person.getDefaultRegion(), 'alpha')
self.assertEquals(sorted(person.getRegionSet()), ['alpha', 'beta'])
......
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