Back to index

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

List of all members.

Public Member Functions

def __init__
def addGroup
 overrides to ease group principal lookups for introspection api
def removeGroup
def addPrincipalToGroup
def removePrincipalFromGroup
def updateGroup
 overrides for api matching/massage
def getGroupById
 introspection interface
def getGroups
def getGroupIds
def getGroupMembers
def allowDeletePrincipal
 capabilties interface impls.
def getGroupInfo
def allowGroupAdd
def allowGroupRemove

Static Public Attributes

string meta_type = "Group Manager"
tuple security = ClassSecurityInfo()

Private Member Functions

def _createGroup
 group wrapping mechanics
def _findGroup
def _verifyGroup

Private Attributes

 _group_principal_map

Detailed Description

Definition at line 59 of file group.py.


Constructor & Destructor Documentation

def PlonePAS.plugins.group.GroupManager.__init__ (   self,
  args,
  kw 
)

Definition at line 64 of file group.py.

00064 
00065     def __init__(self, *args, **kw):
00066         ZODBGroupManager.__init__(self, *args, **kw)
00067         self._group_principal_map = OOBTree() # reverse index of groups->principal


Member Function Documentation

def PlonePAS.plugins.group.GroupManager._createGroup (   self,
  plugins,
  group_id,
  name 
) [private]

group wrapping mechanics

Create group object. For users, this can be done with a
plugin, but I don't care to define one for that now. Just uses
PloneGroup.  But, the code's still here, just commented out.
This method based on PluggableAuthervice._createUser

Definition at line 159 of file group.py.

00159 
00160     def _createGroup(self, plugins, group_id, name):
00161         """ Create group object. For users, this can be done with a
00162         plugin, but I don't care to define one for that now. Just uses
00163         PloneGroup.  But, the code's still here, just commented out.
00164         This method based on PluggableAuthervice._createUser
00165         """
00166 
00167         #factories = plugins.listPlugins(IUserFactoryPlugin)
00168 
00169         #for factory_id, factory in factories:
00170 
00171         #    user = factory.createUser(user_id, name)
00172 
00173         #    if user is not None:
00174         #        return user.__of__(self)
00175 
00176         return PloneGroup(group_id, name).__of__(self)

Here is the caller graph for this function:

def PlonePAS.plugins.group.GroupManager._findGroup (   self,
  plugins,
  group_id,
  title = None,
  request = None 
) [private]
group_id -> decorated_group
This method based on PluggableAuthService._findGroup

Definition at line 178 of file group.py.

00178 
00179     def _findGroup(self, plugins, group_id, title=None, request=None):
00180         """ group_id -> decorated_group
00181         This method based on PluggableAuthService._findGroup
00182         """
00183 
00184         # See if the group can be retrieved from the cache
00185         view_name = '_findGroup-%s' % group_id
00186         keywords = { 'group_id' : group_id
00187                    , 'title' : title
00188                    }
00189         group = self.ZCacheable_get(view_name=view_name
00190                                   , keywords=keywords
00191                                   , default=None
00192                                  )
00193 
00194         if group is None:
00195 
00196             group = self._createGroup(plugins, group_id, title)
00197 
00198             propfinders = plugins.listPlugins(IPropertiesPlugin)
00199             for propfinder_id, propfinder in propfinders:
00200 
00201                 data = propfinder.getPropertiesForUser(group, request)
00202                 if data:
00203                     group.addPropertysheet(propfinder_id, data)
00204 
00205             groups = self._getPAS()._getGroupsForPrincipal(group, request
00206                                                 , plugins=plugins)
00207             group._addGroups(groups)
00208 
00209             rolemakers = plugins.listPlugins(IRolesPlugin)
00210 
00211             for rolemaker_id, rolemaker in rolemakers:
00212                 roles = rolemaker.getRolesForPrincipal(group, request)
00213                 if roles:
00214                     group._addRoles(roles)
00215 
00216             group._addRoles(['Authenticated'])
00217 
00218             # Cache the group if caching is enabled
00219             base_group = aq_base(group)
00220             if getattr(base_group, '_p_jar', None) is None:
00221                 self.ZCacheable_set(base_group
00222                                    , view_name=view_name
00223                                    , keywords=keywords)
00224 
00225         return group.__of__(self)

Here is the call graph for this function:

Here is the caller graph for this function:

def PlonePAS.plugins.group.GroupManager._verifyGroup (   self,
  plugins,
  group_id = None,
  title = None 
) [private]
group_id -> boolean
This method based on PluggableAuthService._verifyUser

Definition at line 227 of file group.py.

00227 
00228     def _verifyGroup(self, plugins, group_id=None, title=None):
00229 
00230         """ group_id -> boolean
00231         This method based on PluggableAuthService._verifyUser
00232         """
00233         criteria = {}
00234 
00235         if group_id is not None:
00236             criteria[ 'id' ] = group_id
00237             criteria[ 'exact_match' ] = True
00238 
00239         if title is not None:
00240             criteria[ 'title' ] = title
00241 
00242         if criteria:
00243             view_name = createViewName('_verifyGroup', group_id)
00244             cached_info = self.ZCacheable_get(view_name=view_name
00245                                              , keywords=criteria
00246                                              , default=None)
00247 
00248             if cached_info is not None:
00249                 return cached_info
00250 
00251             enumerators = plugins.listPlugins(IGroupEnumerationPlugin)
00252 
00253             for enumerator_id, enumerator in enumerators:
00254                 try:
00255                     info = enumerator.enumerateGroups(**criteria)
00256 
00257                     if info:
00258                         id = info[0]['id']
00259                         # Put the computed value into the cache
00260                         self.ZCacheable_set(id
00261                                            , view_name=view_name
00262                                            , keywords=criteria
00263                                            )
00264                         return id
00265 
00266                 except _SWALLOWABLE_PLUGIN_EXCEPTIONS:
00267                     logger.info(
00268                         'PluggableAuthService: GroupEnumerationPlugin %s error',
00269                         enumerator_id, exc_info=1)
00270 
00271         return 0
00272 
00273 classImplements(GroupManager,
00274                 IGroupManagement, IGroupIntrospection, IGroupCapability,
00275                 IDeleteCapability, *implementedBy(ZODBGroupManager))
00276 
00277 InitializeClass(GroupManager)
00278 

Here is the call graph for this function:

Here is the caller graph for this function:

def PlonePAS.plugins.group.GroupManager.addGroup (   self,
  group_id,
  args,
  kw 
)

overrides to ease group principal lookups for introspection api

Definition at line 71 of file group.py.

00071 
00072     def addGroup(self, group_id, *args, **kw):
00073         ZODBGroupManager.addGroup(self, group_id, *args, **kw)
00074         self._group_principal_map[ group_id ] = OOSet()
00075         return True

Here is the caller graph for this function:

def PlonePAS.plugins.group.GroupManager.addPrincipalToGroup (   self,
  principal_id,
  group_id 
)

Definition at line 81 of file group.py.

00081 
00082     def addPrincipalToGroup(self, principal_id, group_id):
00083         ZODBGroupManager.addPrincipalToGroup(self, principal_id, group_id)
00084         self._group_principal_map[ group_id ].insert(principal_id)
00085         return True

Here is the caller graph for this function:

capabilties interface impls.

True iff this plugin can delete a certain group.
This is true if this plugin manages the group.

Definition at line 127 of file group.py.

00127 
00128     def allowDeletePrincipal(self, principal_id):
00129         """True iff this plugin can delete a certain group.
00130         This is true if this plugin manages the group.
00131         """
00132         if self._groups.get(principal_id) is not None:
00133             return 1
00134         return 0

Here is the caller graph for this function:

def PlonePAS.plugins.group.GroupManager.allowGroupAdd (   self,
  user_id,
  group_id 
)
True iff this plugin will allow adding a certain user to a certain group.

Definition at line 139 of file group.py.

00139 
00140     def allowGroupAdd(self, user_id, group_id):
00141         """True iff this plugin will allow adding a certain user to a certain group."""
00142         present = self.getGroupInfo(group_id)
00143         if present: return 1   # if we have a group, we can add users to it
00144                                 # slightly naive, but should be okay.
00145         return 0

Here is the call graph for this function:

def PlonePAS.plugins.group.GroupManager.allowGroupRemove (   self,
  user_id,
  group_id 
)
True iff this plugin will allow removing a certain user from a certain group.

Definition at line 146 of file group.py.

00146 
00147     def allowGroupRemove(self, user_id, group_id):
00148         """True iff this plugin will allow removing a certain user from a certain group."""
00149         present = self.getGroupInfo(group_id)
00150         if not present: return 0   # if we don't have a group, we can't do anything
00151 
00152         group_members = self.getGroupMembers(group_id)
00153         if user_id in group_members: return 1
00154         return 0

Here is the call graph for this function:

def PlonePAS.plugins.group.GroupManager.getGroupById (   self,
  group_id,
  default = None 
)

introspection interface

Definition at line 103 of file group.py.

00103 
00104     def getGroupById(self, group_id, default=None):
00105         plugins = self._getPAS()._getOb('plugins')
00106 
00107         group_id = self._verifyGroup(plugins, group_id=group_id)
00108         title = None
00109 
00110         if not group_id:
00111             return default
00112 
00113         return self._findGroup(plugins, group_id, title)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 117 of file group.py.

00117 
00118     def getGroupIds(self):
00119         return self.listGroupIds()

Here is the call graph for this function:

Here is the caller graph for this function:

def PlonePAS.plugins.group.GroupManager.getGroupInfo (   self,
  group_id 
)
Over-ride parent to not explode when getting group info dict by group id.

Definition at line 135 of file group.py.

00135 
00136     def getGroupInfo( self, group_id ):
00137         """Over-ride parent to not explode when getting group info dict by group id."""
00138         return self._groups.get(group_id,None)

Here is the caller graph for this function:

Definition at line 120 of file group.py.

00120 
00121     def getGroupMembers(self, group_id):
00122         return tuple(self._group_principal_map.get(group_id,()))

Here is the caller graph for this function:

Definition at line 114 of file group.py.

00114 
00115     def getGroups(self):
00116         return map(self.getGroupById, self.getGroupIds())

Here is the call graph for this function:

Here is the caller graph for this function:

def PlonePAS.plugins.group.GroupManager.removeGroup (   self,
  group_id 
)

Definition at line 76 of file group.py.

00076 
00077     def removeGroup(self, group_id):
00078         ZODBGroupManager.removeGroup(self, group_id)
00079         del self._group_principal_map[ group_id ]
00080         return True

Here is the caller graph for this function:

def PlonePAS.plugins.group.GroupManager.removePrincipalFromGroup (   self,
  principal_id,
  group_id 
)

Definition at line 86 of file group.py.

00086 
00087     def removePrincipalFromGroup(self, principal_id, group_id):
00088         already = ZODBGroupManager.removePrincipalFromGroup(self, principal_id, group_id)
00089         if already: self._group_principal_map[ group_id ].remove(principal_id)
00090         return True

Here is the caller graph for this function:

def PlonePAS.plugins.group.GroupManager.updateGroup (   self,
  group_id,
  kw 
)

overrides for api matching/massage

Definition at line 94 of file group.py.

00094 
00095     def updateGroup(self, group_id, **kw):
00096         kw['title'].setdefault('')
00097         kw['description'].setdefault('')
00098         ZODBGroupManager.updateGroup(self, group_id, **kw)
00099         return True

Here is the caller graph for this function:


Member Data Documentation

Definition at line 66 of file group.py.

string PlonePAS.plugins.group.GroupManager.meta_type = "Group Manager" [static]

Definition at line 61 of file group.py.

tuple PlonePAS.plugins.group.GroupManager.security = ClassSecurityInfo() [static]

Definition at line 62 of file group.py.


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