diff -r f1d9e3b9e51e -r d8083b2ae4d6 entities/authobjs.py --- a/entities/authobjs.py Wed May 11 13:41:21 2011 +0200 +++ b/entities/authobjs.py Fri May 13 10:10:19 2011 +0200 @@ -29,9 +29,21 @@ fetch_attrs, fetch_order = fetch_config(['name']) fetch_unrelated_order = fetch_order - def db_key_name(self): - """XXX goa specific""" - return self.get('name') + def grant_permission(self, entity, pname, plabel=None): + """grant local `pname` permission on `entity` to this group using + :class:`CWPermission`. + + If a similar permission already exists, add the group to it, else create + a new one. + """ + if not self._cw.execute( + 'SET X require_group G WHERE E eid %(e)s, G eid %(g)s, ' + 'E require_permission X, X name %(name)s, X label %(label)s', + {'e': entity.eid, 'g': self.eid, + 'name': pname, 'label': plabel}): + self._cw.create_entity('CWPermission', name=pname, label=plabel, + require_group=self, + reverse_require_permission=entity) class CWUser(AnyEntity): @@ -156,10 +168,6 @@ dc_long_title = name - def db_key_name(self): - """XXX goa specific""" - return self.get('login') - from logilab.common.deprecation import class_renamed EUser = class_renamed('EUser', CWUser) EGroup = class_renamed('EGroup', CWGroup)