Back to index

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

List of all members.

Public Member Functions

def __init__
def getRolesInContext
def checkLocalRolesAllowed
def getAllLocalRolesInContext

Public Attributes

 id
 title

Static Public Attributes

string meta_type = "Local Roles Manager"
tuple security = ClassSecurityInfo()

Private Attributes

 _id

Detailed Description

Class incorporating local role storage with
PlonePAS-specific local role permission checking.

Definition at line 49 of file local_role.py.


Constructor & Destructor Documentation

def PlonePAS.plugins.local_role.LocalRolesManager.__init__ (   self,
  id,
  title = None 
)

Definition at line 57 of file local_role.py.

00057 
00058     def __init__(self, id, title=None):
00059         self._id = self.id = id
00060         self.title = title


Member Function Documentation

def PlonePAS.plugins.local_role.LocalRolesManager.checkLocalRolesAllowed (   self,
  user,
  object,
  object_roles 
)

Definition at line 106 of file local_role.py.

00106 
00107     def checkLocalRolesAllowed( self, user, object, object_roles ):
00108         # Still have not found a match, so check local roles. We do
00109         # this manually rather than call getRolesInContext so that
00110         # we can incur only the overhead required to find a match.
00111         inner_obj = aq_inner( object )
00112         user_id = user.getId()
00113         # [ x.getId() for x in user.getGroups() ]
00114         group_ids = user.getGroups()
00115 
00116         principal_ids = list( group_ids )
00117         principal_ids.insert( 0, user_id )
00118 
00119         while 1:
00120 
00121             local_roles = getattr( inner_obj, '__ac_local_roles__', None )
00122 
00123             if local_roles and callable( local_roles ):
00124                 local_roles = local_roles()
00125 
00126             if local_roles:
00127                 dict = local_roles
00128 
00129                 for principal_id in principal_ids:
00130                     local_roles = dict.get( principal_id, [] )
00131 
00132                     # local_roles is empty most of the time, where as
00133                     # object_roles is usually not.
00134                     if not local_roles:
00135                         continue
00136 
00137                     for role in object_roles:
00138                         if role in local_roles:
00139                             if user._check_context( object ):
00140                                 return 1
00141                             return 0
00142 
00143             inner = aq_inner( inner_obj )
00144             parent = aq_parent( inner )
00145 
00146             if getattr(inner_obj, '__ac_local_roles_block__', None):
00147                 break
00148 
00149             if parent is not None:
00150                 inner_obj = parent
00151                 continue
00152 
00153             new = getattr( inner_obj, 'im_self', None )
00154 
00155             if new is not None:
00156                 inner_obj = aq_inner( new )
00157                 continue
00158 
00159             break
00160 
00161         return None

Definition at line 162 of file local_role.py.

00162 
00163     def getAllLocalRolesInContext(self, context):
00164         roles = {}
00165         object = aq_inner( context )
00166 
00167         while True:
00168 
00169             local_roles = getattr(object, '__ac_local_roles__', None)
00170 
00171             if local_roles and callable( local_roles ):
00172                 local_roles = local_roles()
00173 
00174             if local_roles:
00175                     
00176                 dict = local_roles
00177 
00178                 for principal, localroles in dict.items():
00179                     if not principal in roles:
00180                         roles[principal] = Set()
00181 
00182                     roles[principal].update(localroles)
00183 
00184             inner = aq_inner( object )
00185             parent = aq_parent( inner )
00186 
00187             if getattr(object, '__ac_local_roles_block__', None):
00188                 break
00189 
00190             if parent is not None:
00191                 object = parent
00192                 continue
00193 
00194             new = getattr( object, 'im_self', None )
00195 
00196             if new is not None:
00197                 object = aq_inner( new )
00198                 continue
00199 
00200             break
00201 
00202         return roles
00203 
00204 classImplements(LocalRolesManager,
00205                 ILocalRolesPlugin, *implementedBy(LocalRolePlugin))
00206 
00207 InitializeClass(LocalRolesManager)

Here is the call graph for this function:

Definition at line 62 of file local_role.py.

00062 
00063     def getRolesInContext( self, user, object):
00064         user_id = user.getId()
00065         group_ids = user.getGroups()
00066 
00067         principal_ids = list( group_ids )
00068         principal_ids.insert( 0, user_id )
00069 
00070         local = {}
00071         object = aq_inner( object )
00072 
00073         while 1:
00074             local_roles = getattr( object, '__ac_local_roles__', None )
00075 
00076             if local_roles and callable( local_roles ):
00077                 local_roles = local_roles()
00078             
00079             if local_roles:
00080                 dict = local_roles
00081 
00082                 for principal_id in principal_ids:
00083                     for role in dict.get( principal_id, [] ):
00084                         local[ role ] = 1
00085 
00086             inner = aq_inner( object )
00087             parent = aq_parent( inner )
00088 
00089             if getattr(object, '__ac_local_roles_block__', None):
00090                 break
00091 
00092             if parent is not None:
00093                 object = parent
00094                 continue
00095 
00096             new = getattr( object, 'im_self', None )
00097 
00098             if new is not None:
00099                 object = aq_inner( new )
00100                 continue
00101 
00102             break
00103 
00104         return local.keys()


Member Data Documentation

Definition at line 58 of file local_role.py.

Definition at line 58 of file local_role.py.

string PlonePAS.plugins.local_role.LocalRolesManager.meta_type = "Local Roles Manager" [static]

Definition at line 54 of file local_role.py.

tuple PlonePAS.plugins.local_role.LocalRolesManager.security = ClassSecurityInfo() [static]

Definition at line 55 of file local_role.py.

Definition at line 59 of file local_role.py.


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