equal
deleted
inserted
replaced
16 # You should have received a copy of the GNU Lesser General Public License along |
16 # You should have received a copy of the GNU Lesser General Public License along |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 """entity classes user and group entities""" |
18 """entity classes user and group entities""" |
19 |
19 |
20 __docformat__ = "restructuredtext en" |
20 __docformat__ = "restructuredtext en" |
|
21 |
|
22 from six import string_types |
21 |
23 |
22 from logilab.common.decorators import cached |
24 from logilab.common.decorators import cached |
23 |
25 |
24 from cubicweb import Unauthorized |
26 from cubicweb import Unauthorized |
25 from cubicweb.entities import AnyEntity, fetch_config |
27 from cubicweb.entities import AnyEntity, fetch_config |
124 """return the number of the given group(s) in which the user is |
126 """return the number of the given group(s) in which the user is |
125 |
127 |
126 :type groups: str or iterable(str) |
128 :type groups: str or iterable(str) |
127 :param groups: a group name or an iterable on group names |
129 :param groups: a group name or an iterable on group names |
128 """ |
130 """ |
129 if isinstance(groups, basestring): |
131 if isinstance(groups, string_types): |
130 groups = frozenset((groups,)) |
132 groups = frozenset((groups,)) |
131 elif isinstance(groups, (tuple, list)): |
133 elif isinstance(groups, (tuple, list)): |
132 groups = frozenset(groups) |
134 groups = frozenset(groups) |
133 return len(groups & self.groups) # XXX return the resulting set instead of its size |
135 return len(groups & self.groups) # XXX return the resulting set instead of its size |
134 |
136 |