Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes
PlonePAS.plugins.role.GroupAwareRoleManager Class Reference
Inheritance diagram for PlonePAS.plugins.role.GroupAwareRoleManager:
Inheritance graph
[legend]
Collaboration diagram for PlonePAS.plugins.role.GroupAwareRoleManager:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def updateRolesList
def manage_afterAdd
def assignRolesToPrincipal
def getRolesForPrincipal
def allowRoleAssign
 implement IAssignRoleCapability
def listRoleIds
def listRoleInfo
def getRoleInfo
def getRoleInfo

Static Public Attributes

string meta_type = "Group Aware Role Manager"
tuple security = ClassSecurityInfo()
tuple assignRolesToPrincipal = postonly(assignRolesToPrincipal)

Detailed Description

Definition at line 53 of file role.py.


Member Function Documentation

def PlonePAS.plugins.role.GroupAwareRoleManager.allowRoleAssign (   self,
  user_id,
  role_id 
)

implement IAssignRoleCapability

True iff this plugin will allow assigning a certain user a certain role.

Definition at line 118 of file role.py.

00118 
00119     def allowRoleAssign(self, user_id, role_id):
00120         """True iff this plugin will allow assigning a certain user a certain role."""
00121         present = self.getRoleInfo(role_id)
00122         if present: return 1   # if we have a role, we can assign it
00123                                # slightly naive, but should be okay.
00124         return 0

Here is the call graph for this function:

def PlonePAS.plugins.role.GroupAwareRoleManager.assignRolesToPrincipal (   self,
  roles,
  principal_id,
  REQUEST = None 
)
Assign a specific set of roles, and only those roles, to a principal.

o no return value

o Raise KeyError if a role_id is unknown.

Definition at line 82 of file role.py.

00082 
00083     def assignRolesToPrincipal( self, roles, principal_id, REQUEST=None ):
00084         """ Assign a specific set of roles, and only those roles, to a principal.
00085 
00086         o no return value
00087 
00088         o Raise KeyError if a role_id is unknown.
00089         """
00090         for role_id in roles:
00091             if role_id not in ('Authenticated','Anonymous','Owner'):
00092                 try:
00093                     role_info = self._roles[ role_id ] # raise KeyError if unknown!
00094                 except KeyError:
00095                     # Lazily update our roles list and try again
00096                     self.updateRolesList()
00097                     role_info = self._roles[ role_id ] # raise KeyError if unknown!
00098 
00099 
        self._principal_roles[ principal_id ] = tuple(roles)

Here is the call graph for this function:

Definition at line 133 of file role.py.

00133 
00134     def getRoleInfo(self, role_id):
00135         if role_id not in self._roles:
00136             self.updateRolesList()
00137         return ZODBRoleManager.getRoleInfo(self, role_id)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 138 of file role.py.

00138 
00139     def getRoleInfo(self, role_id):
00140         if role_id not in self._roles:
00141             self.updateRolesList()
00142         return ZODBRoleManager.getRoleInfo(self, role_id)
00143 
00144 
00145 classImplements(GroupAwareRoleManager,
00146                 IAssignRoleCapability, *implementedBy(ZODBRoleManager))
00147 
00148 InitializeClass( GroupAwareRoleManager )

Here is the call graph for this function:

def PlonePAS.plugins.role.GroupAwareRoleManager.getRolesForPrincipal (   self,
  principal,
  request = None 
)
See IRolesPlugin.

Definition at line 103 of file role.py.

00103 
00104     def getRolesForPrincipal( self, principal, request=None ):
00105         """ See IRolesPlugin.
00106         """
00107         roles = []
00108         principal_ids = [principal.getId()]
00109         # not all user objects are propertied users with groups support.
00110         # theres no interface for now - so use an ugly hasattr
00111         if hasattr(principal, 'getGroups'):
00112             principal_ids.extend( principal.getGroups() )
00113         for pid in principal_ids:
00114             roles.extend( self._principal_roles.get( pid, () ) )
00115         return tuple( unique( roles ) )

Definition at line 125 of file role.py.

00125 
00126     def listRoleIds(self):
00127         self.updateRolesList()
00128         return ZODBRoleManager.listRoleIds(self)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 129 of file role.py.

00129 
00130     def listRoleInfo(self):
00131         self.updateRolesList()
00132         return ZODBRoleManager.listRoleInfo(self)

Here is the call graph for this function:

def PlonePAS.plugins.role.GroupAwareRoleManager.manage_afterAdd (   self,
  item,
  container 
)

Definition at line 71 of file role.py.

00071 
00072     def manage_afterAdd( self, item, container ):
00073 
00074         try:
00075             self.addRole( 'Manager' )
00076         except KeyError:
00077             pass
00078 
00079         if item is self:
00080             self.updateRolesList()

Here is the call graph for this function:

Definition at line 59 of file role.py.

00059 
00060     def updateRolesList(self):
00061         role_holder = aq_parent( aq_inner( self._getPAS() ) )
00062         for role in getattr( role_holder, '__ac_roles__', () ):
00063             if role not in ('Anonymous', 'Authenticated') and \
00064                     role not in self._roles:
00065                 try:
00066                     self.addRole( role )
00067                 except KeyError:
00068                     pass
00069 

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 100 of file role.py.

string PlonePAS.plugins.role.GroupAwareRoleManager.meta_type = "Group Aware Role Manager" [static]

Definition at line 55 of file role.py.

tuple PlonePAS.plugins.role.GroupAwareRoleManager.security = ClassSecurityInfo() [static]

Definition at line 57 of file role.py.


The documentation for this class was generated from the following file: