entities/authobjs.py
changeset 4252 6c4f109c2b03
parent 3890 d7a270f50f54
parent 4246 c95b8c7e5fb2
child 4436 294e084f1263
equal deleted inserted replaced
4251:3c6569be1f86 4252:6c4f109c2b03
     1 """entity classes user and group entities
     1 """entity classes user and group entities
     2 
     2 
     3 :organization: Logilab
     3 :organization: Logilab
     4 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
     4 :copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
     5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
     5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
     6 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
     6 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
     7 """
     7 """
     8 __docformat__ = "restructuredtext en"
     8 __docformat__ = "restructuredtext en"
     9 
     9 
    18     fetch_unrelated_order = fetch_order
    18     fetch_unrelated_order = fetch_order
    19 
    19 
    20     def db_key_name(self):
    20     def db_key_name(self):
    21         """XXX goa specific"""
    21         """XXX goa specific"""
    22         return self.get('name')
    22         return self.get('name')
       
    23 
    23 
    24 
    24 class CWUser(AnyEntity):
    25 class CWUser(AnyEntity):
    25     __regid__ = 'CWUser'
    26     __regid__ = 'CWUser'
    26     fetch_attrs, fetch_order = fetch_config(['login', 'firstname', 'surname'])
    27     fetch_attrs, fetch_order = fetch_config(['login', 'firstname', 'surname'])
    27     fetch_unrelated_order = fetch_order
    28     fetch_unrelated_order = fetch_order
    75         """
    76         """
    76         if isinstance(groups, basestring):
    77         if isinstance(groups, basestring):
    77             groups = frozenset((groups,))
    78             groups = frozenset((groups,))
    78         elif isinstance(groups, (tuple, list)):
    79         elif isinstance(groups, (tuple, list)):
    79             groups = frozenset(groups)
    80             groups = frozenset(groups)
    80         return len(groups & self.groups)
    81         return len(groups & self.groups) # XXX return the resulting set instead of its size
    81 
    82 
    82     def is_in_group(self, group):
    83     def is_in_group(self, group):
    83         """convience / shortcut method to test if the user belongs to `group`
    84         """convience / shortcut method to test if the user belongs to `group`
    84         """
    85         """
    85         return self.matching_groups(group) == 1
    86         return group in self._groups
    86 
    87 
    87     def is_anonymous(self):
    88     def is_anonymous(self):
    88         """ checks if user is an anonymous user"""
    89         """ checks if user is an anonymous user"""
    89         #FIXME on the web-side anonymous user is detected according
    90         #FIXME on the web-side anonymous user is detected according
    90         # to config['anonymous-user'], we don't have this info on
    91         # to config['anonymous-user'], we don't have this info on