From 6f0d3d67ce08ae8a96a8b63910fc53905f4c2b61 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Tue, 20 Apr 2010 11:54:11 +0000
Subject: [PATCH] Fix set value accessors (like setRegionValueSet). They were
 not filtering out duplicates

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34681 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/Accessor/Value.py     | 3 ++-
 product/ERP5Type/Base.py               | 2 +-
 product/ERP5Type/tests/testERP5Type.py | 1 +
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/product/ERP5Type/Accessor/Value.py b/product/ERP5Type/Accessor/Value.py
index 7a4f3db04c..359df5a6e5 100644
--- a/product/ERP5Type/Accessor/Value.py
+++ b/product/ERP5Type/Accessor/Value.py
@@ -48,7 +48,8 @@ class SetSetter(BaseSetter):
     def __call__(self, instance, *args, **kw):
       if self._warning:
         LOG("ERP5Type Deprecated Setter Id:",0, self._id)
-      instance._setValue(self._key, args[0],
+      value = set(args[0])
+      instance._setValue(self._key, value,
                                                 spec=kw.get('spec',()),
                                                 filter=kw.get('filter', None),
                                                 portal_type=kw.get('portal_type',()),
diff --git a/product/ERP5Type/Base.py b/product/ERP5Type/Base.py
index 859bf9606e..cf74e8a402 100644
--- a/product/ERP5Type/Base.py
+++ b/product/ERP5Type/Base.py
@@ -2004,7 +2004,7 @@ class Base( CopyContainer,
       # We have been provided a string
       path = target
       if path.startswith(start_string): path = path[start_string_len:] # Prevent duplicating base category
-    elif isinstance(target, (tuple, list)):
+    elif isinstance(target, (tuple, list, set, frozenset)):
       # We have been provided a list or tuple
       path_list = []
       for target_item in target:
diff --git a/product/ERP5Type/tests/testERP5Type.py b/product/ERP5Type/tests/testERP5Type.py
index cb102391ff..adab7c8dac 100644
--- a/product/ERP5Type/tests/testERP5Type.py
+++ b/product/ERP5Type/tests/testERP5Type.py
@@ -675,6 +675,7 @@ class TestPropertySheet:
       person.setRegionValueList([alpha, alpha])
       self.assertEquals(person.getRegionList(), ['alpha', 'alpha'])
       person.setRegionValueSet([alpha, alpha])
+      self.assertEquals(person.getRegionList(), ['alpha'])
       self.assertEquals(person.getRegionSet(), ['alpha'])
       person.setRegionValueList([alpha, beta, alpha])
       self.assertEquals(person.getRegionList(), ['alpha', 'beta', 'alpha'])
-- 
2.30.9