Commit 9eee056a authored by Julien Muchembled's avatar Julien Muchembled

Fix _set*UidSet accessors

parent 6e6dbb01
......@@ -48,8 +48,7 @@ class SetSetter(BaseSetter):
def __call__(self, instance, *args, **kw):
if self._warning:
LOG("ERP5Type Deprecated Setter Id:",0, self._id)
value = set(args[0])
instance._setValue(self._key, value,
instance._setValue(self._key, set(args[0]),
spec=kw.get('spec',()),
filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()),
......@@ -451,7 +450,7 @@ class UidSetSetter(BaseSetter):
def __call__(self, instance, *args, **kw):
if self._warning:
LOG("ERP5Type Deprecated Getter Id:",0, self._id)
instance._setValueUidList(self._key, args[0],
instance._setValueUidList(self._key, set(args[0]),
spec=kw.get('spec',()),
filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()),
......
......@@ -2013,11 +2013,8 @@ class Base( CopyContainer,
checked_permission=None):
# We must do an ordered list so we can not use the previous method
# self._setValue(id, self.portal_catalog.getObjectList(uids), spec=spec)
references = []
if type(uids) not in (type(()), type([])):
uids = [uids]
for uid in uids:
references.append(self.portal_catalog.getObject(uid))
references = map(self.getPortalObject().portal_catalog.getObject,
(uids,) if isinstance(uids, (int, long)) else uids)
self._setValue(id, references, spec=spec, filter=filter, portal_type=portal_type,
keep_default=keep_default, checked_permission=checked_permission)
......
......@@ -722,27 +722,21 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
self.assertEquals(person.getDefaultRegion(), 'alpha')
person.setRegionUid(alpha.getUid())
self.assertEquals(person.getRegion(), 'alpha')
person.setRegionUidList([alpha.getUid(), alpha.getUid()])
self.assertEquals(person.getRegionList(), ['alpha', 'alpha'])
person.setRegionUidList([beta.getUid(), beta.getUid()])
self.assertEquals(person.getRegionList(), ['beta', 'beta'])
person.setRegionUidSet([alpha.getUid(), alpha.getUid()])
self.assertEquals(person.getRegionSet(), ['alpha'])
self.assertEquals(person.getRegionList(), ['alpha'])
person.setRegionUidList([alpha.getUid(), beta.getUid(), alpha.getUid()])
self.assertEquals(person.getRegionList(), ['alpha', 'beta', 'alpha'])
person.setRegionUidSet([alpha.getUid(), beta.getUid(), alpha.getUid()])
result = person.getRegionSet()
result.sort()
self.assertEquals(result, ['alpha', 'beta'])
self.assertEquals(sorted(person.getRegionSet()), ['alpha', 'beta'])
person.setDefaultRegionUid(beta.getUid())
self.assertEquals(person.getDefaultRegion(), 'beta')
result = person.getRegionSet()
result.sort()
self.assertEquals(result, ['alpha', 'beta'])
self.assertEquals(sorted(person.getRegionSet()), ['alpha', 'beta'])
self.assertEquals(person.getRegionList(), ['beta', 'alpha'])
person.setDefaultRegionUid(alpha.getUid())
self.assertEquals(person.getDefaultRegion(), 'alpha')
result = person.getRegionSet()
result.sort()
self.assertEquals(result, ['alpha', 'beta'])
self.assertEquals(sorted(person.getRegionSet()), ['alpha', 'beta'])
self.assertEquals(person.getRegionList(), ['alpha', 'beta'])
# Test accessor on documents rather than on categories
person.setDefaultRegionUid(person.getUid())
......
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