27 class CWGroup(AnyEntity): |
27 class CWGroup(AnyEntity): |
28 __regid__ = 'CWGroup' |
28 __regid__ = 'CWGroup' |
29 fetch_attrs, fetch_order = fetch_config(['name']) |
29 fetch_attrs, fetch_order = fetch_config(['name']) |
30 fetch_unrelated_order = fetch_order |
30 fetch_unrelated_order = fetch_order |
31 |
31 |
|
32 def grant_permission(self, entity, pname, plabel=None): |
|
33 """grant local `pname` permission on `entity` to this group using |
|
34 :class:`CWPermission`. |
|
35 |
|
36 If a similar permission already exists, add the group to it, else create |
|
37 a new one. |
|
38 """ |
|
39 if not self._cw.execute( |
|
40 'SET X require_group G WHERE E eid %(e)s, G eid %(g)s, ' |
|
41 'E require_permission X, X name %(name)s, X label %(label)s', |
|
42 {'e': entity.eid, 'g': self.eid, |
|
43 'name': pname, 'label': plabel}): |
|
44 self._cw.create_entity('CWPermission', name=pname, label=plabel, |
|
45 require_group=self, |
|
46 reverse_require_permission=entity) |
32 |
47 |
33 |
48 |
34 class CWUser(AnyEntity): |
49 class CWUser(AnyEntity): |
35 __regid__ = 'CWUser' |
50 __regid__ = 'CWUser' |
36 fetch_attrs, fetch_order = fetch_config(['login', 'firstname', 'surname']) |
51 fetch_attrs, fetch_order = fetch_config(['login', 'firstname', 'surname']) |