Example #1
0
File: role.py Project: dtgit/dtedu
 def getRolesForPrincipal(self, principal, request=None):
     """ See IRolesPlugin.
     """
     roles = []
     principal_ids = [principal.getId()]
     # not all user objects are propertied users with groups support.
     # theres no interface for now - so use an ugly hasattr
     if hasattr(principal, "getGroups"):
         principal_ids.extend(principal.getGroups())
     for pid in principal_ids:
         roles.extend(self._principal_roles.get(pid, ()))
     return tuple(unique(roles))
Example #2
0
 def getRolesInContext(self, object):
     lrmanagers = self._getLocalRolesPlugins()
     roles = []
     for lrid, lrmanager in lrmanagers:
         roles.extend(lrmanager.getRolesInContext(self, object))
     return unique(roles)