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

Fix _set*UidSet accessors

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