don't use matching_groups() for is_in_group implementation stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 18 Jan 2010 11:50:34 +0100
branchstable
changeset 4246 c95b8c7e5fb2
parent 4245 ff8e355dbc97
child 4247 b1d79216d930
don't use matching_groups() for is_in_group implementation
entities/authobjs.py
--- a/entities/authobjs.py	Fri Jan 15 09:36:49 2010 +0100
+++ b/entities/authobjs.py	Mon Jan 18 11:50:34 2010 +0100
@@ -21,6 +21,7 @@
         """XXX goa specific"""
         return self.get('name')
 
+
 class CWUser(AnyEntity):
     id = 'CWUser'
     fetch_attrs, fetch_order = fetch_config(['login', 'firstname', 'surname'])
@@ -76,12 +77,12 @@
             groups = frozenset((groups,))
         elif isinstance(groups, (tuple, list)):
             groups = frozenset(groups)
-        return len(groups & self.groups)
+        return len(groups & self.groups) # XXX return the resulting set instead of its size
 
     def is_in_group(self, group):
         """convience / shortcut method to test if the user belongs to `group`
         """
-        return self.matching_groups(group) == 1
+        return group in self._groups
 
     def is_anonymous(self):
         """ checks if user is an anonymous user"""