class LocalPrincipalRoleMap(object): interface.implements(IPrincipalRoleMap) def __init__(self, context): folder = context.__parent__ pinfo = folder.principalInfo(folder.prefix + context.__name__) self.principal = IFoundPrincipalFactory(pinfo)(getUtility(IAuthentication)) self.groups = IPrincipalGroups(self.principal) def getPrincipalsForRole(self, role_id): if role_id == 'content.Owner': return (self.principal.id, Allow), return () def getRolesForPrincipal(self, principal_id): if principal_id == self.principal.id: return ('content.Owner', Allow), for group in self.groups.getGroups(): if principal_id in getattr(group, 'leaders', ()): return (('team.Leader', Allow), ('team.Member', Allow)) elif IMemberGetterGroup.providedBy(group) and principal_id in group.getMembers(): return (('team.Member', Allow),) return () def getSetting(self, role_id, principal_id): return Unset def getPrincipalsAndRoles(self): pass
def __init__(self, context): folder = context.__parent__ pinfo = folder.principalInfo(folder.prefix + context.__name__) self.principal = IFoundPrincipalFactory(pinfo)(getUtility(IAuthentication)) self.groups = IPrincipalGroups(self.principal)