Back to index

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

List of all members.

Public Member Functions

def __init__
def enumerateGroups
def getGroupsForPrincipal
def listGroupIds
def listGroupInfo
def getGroupInfo
def addGroup
def updateGroup
def removeGroup
def listAvailablePrincipals
def listAssignedPrincipals
def addPrincipalToGroup
def removePrincipalFromGroup
def manage_addGroup
def manage_updateGroup
def manage_removeGroups
def manage_addPrincipalsToGroup
def manage_removePrincipalsFromGroup

Public Attributes

 id
 title

Static Public Attributes

string meta_type = 'ZODB Group Manager'
tuple security = ClassSecurityInfo()
tuple addPrincipalToGroup = postonly(addPrincipalToGroup)
tuple removePrincipalFromGroup = postonly(removePrincipalFromGroup)
tuple manage_options
tuple manage_widgets
tuple manage_groups
tuple manage_twoLists
tuple manage_removeGroups = postonly(manage_removeGroups)
tuple manage_addPrincipalsToGroup = postonly(manage_addPrincipalsToGroup)
tuple manage_removePrincipalsFromGroup = postonly(manage_removePrincipalsFromGroup)

Private Attributes

 _id
 _groups
 _principal_groups

Detailed Description

PAS plugin for managing groups, and groups of groups in the ZODB

Definition at line 58 of file ZODBGroupManager.py.


Constructor & Destructor Documentation

Definition at line 66 of file ZODBGroupManager.py.

00066 
00067     def __init__(self, id, title=None):
00068 
00069         self._id = self.id = id
00070         self.title = title
00071         self._groups = OOBTree()
00072         self._principal_groups = OOBTree()


Member Function Documentation

def PluggableAuthService.plugins.ZODBGroupManager.ZODBGroupManager.addGroup (   self,
  group_id,
  title = None,
  description = None 
)
Add 'group_id' to the list of groups managed by this object.

o Raise KeyError on duplicate.

Definition at line 173 of file ZODBGroupManager.py.

00173 
00174     def addGroup( self, group_id, title=None, description=None ):
00175 
00176         """ Add 'group_id' to the list of groups managed by this object.
00177 
00178         o Raise KeyError on duplicate.
00179         """
00180         if self._groups.get( group_id ) is not None:
00181             raise KeyError, 'Duplicate group ID: %s' % group_id
00182 
00183         self._groups[ group_id ] = { 'id' : group_id
00184                                    , 'title' : title
00185                                    , 'description' : description
00186                                    }

Here is the caller graph for this function:

def PluggableAuthService.plugins.ZODBGroupManager.ZODBGroupManager.addPrincipalToGroup (   self,
  principal_id,
  group_id,
  REQUEST = None 
)
Add a principal to a group.

o Return a boolean indicating whether a new assignment was created.

o Raise KeyError if 'group_id' is unknown.

Definition at line 266 of file ZODBGroupManager.py.

00266 
00267     def addPrincipalToGroup( self, principal_id, group_id, REQUEST=None ):
00268 
00269         """ Add a principal to a group.
00270 
00271         o Return a boolean indicating whether a new assignment was created.
00272 
00273         o Raise KeyError if 'group_id' is unknown.
00274         """
00275         group_info = self._groups[ group_id ] # raise KeyError if unknown!
00276 
00277         current = self._principal_groups.get( principal_id, () )
00278         already = group_id in current
00279 
00280         if not already:
00281             new = current + ( group_id, )
00282             self._principal_groups[ principal_id ] = new
00283 
        return not already

Here is the caller graph for this function:

def PluggableAuthService.plugins.ZODBGroupManager.ZODBGroupManager.enumerateGroups (   self,
  id = None,
  title = None,
  exact_match = False,
  sort_by = None,
  max_results = None,
  kw 
)
See IGroupEnumerationPlugin.

Definition at line 84 of file ZODBGroupManager.py.

00084 
00085                         ):
00086 
00087         """ See IGroupEnumerationPlugin.
00088         """
00089         group_info = []
00090         group_ids = []
00091         plugin_id = self.getId()
00092 
00093         if isinstance( id, str ):
00094             id = [ id ]
00095 
00096         if isinstance( title, str ):
00097             title = [ title ]
00098 
00099         if exact_match and ( id or title ):
00100 
00101             if id:
00102                 group_ids.extend( id )
00103             elif title:
00104                 group_ids.extend( title )
00105 
00106         if group_ids:
00107             group_filter = None
00108 
00109         else:   # Searching
00110             group_ids = self.listGroupIds()
00111             group_filter = _ZODBGroupFilter( id, title, **kw )
00112 
00113         for group_id in group_ids:
00114 
00115             if self._groups.get( group_id, None ):
00116                 e_url = '%s/manage_groups' % self.getId()
00117                 p_qs = 'group_id=%s' % group_id
00118                 m_qs = 'group_id=%s&assign=1' % group_id
00119 
00120                 info = {}
00121                 info.update( self._groups[ group_id ] )
00122 
00123                 info[ 'pluginid' ] = plugin_id
00124                 info[ 'properties_url' ] = '%s?%s' % ( e_url, p_qs )
00125                 info[ 'members_url' ] = '%s?%s' % ( e_url, m_qs )
00126 
00127                 info[ 'id' ] = '%s%s' % (self.prefix, info['id'])
00128 
00129                 if not group_filter or group_filter( info ):
00130                     group_info.append( info )
00131 
00132         return tuple( group_info )

group_id -> {}

Definition at line 166 of file ZODBGroupManager.py.

00166 
00167     def getGroupInfo( self, group_id ):
00168 
00169         """ group_id -> {}
00170         """
00171         return self._groups[ group_id ]

See IGroupsPlugin.

Definition at line 137 of file ZODBGroupManager.py.

00137 
00138     def getGroupsForPrincipal( self, principal, request=None ):
00139 
00140         """ See IGroupsPlugin.
00141         """
00142         unadorned = self._principal_groups.get( principal.getId(), () )
00143         return tuple(['%s%s' % (self.prefix, x) for x in unadorned])

Return a list of principal IDs belonging to a group.

Definition at line 244 of file ZODBGroupManager.py.

00244 
00245     def listAssignedPrincipals( self, group_id ):
00246 
00247         """ Return a list of principal IDs belonging to a group.
00248         """
00249         result = []
00250 
00251         for k, v in self._principal_groups.items():
00252             if group_id in v:
00253                 # should be one and only one mapping to 'k'
00254 
00255                 parent = aq_parent( self )
00256                 info = parent.searchPrincipals( id=k, exact_match=True )
00257                 assert( len( info ) in ( 0, 1 ) )
00258                 if len( info ) == 0:
00259                     title = '<%s: not found>' % k
00260                 else:
00261                     title = info[0].get( 'title', k )
00262                 result.append( ( k, title ) )
00263 
00264         return result

Here is the call graph for this function:

Return a list of principal IDs to that can belong to the group.

o If supplied, 'search_id' constrains the principal IDs;  if not,
  return empty list.

o Omit principals with existing assignments.

Definition at line 215 of file ZODBGroupManager.py.

00215 
00216     def listAvailablePrincipals( self, group_id, search_id ):
00217 
00218         """ Return a list of principal IDs to that can belong to the group.
00219 
00220         o If supplied, 'search_id' constrains the principal IDs;  if not,
00221           return empty list.
00222 
00223         o Omit principals with existing assignments.
00224         """
00225         result = []
00226 
00227         if search_id:  # don't bother searching if no criteria
00228 
00229             parent = aq_parent( self )
00230 
00231             for info in parent.searchPrincipals( max_results=20
00232                                                , sort_by='id'
00233                                                , id=search_id
00234                                                , exact_match=False
00235                                                ):
00236                 id = info[ 'id' ]
00237                 title = info.get( 'title', id )
00238                 if ( group_id not in self._principal_groups.get( id, () )
00239                  and group_id != id ):
00240                     result.append( ( id, title ) )
00241 
00242         return result

-> ( group_id_1, ... group_id_n )

Definition at line 148 of file ZODBGroupManager.py.

00148 
00149     def listGroupIds( self ):
00150 
00151         """ -> ( group_id_1, ... group_id_n )
00152         """
00153         return self._groups.keys()

Here is the caller graph for this function:

-> ( {}, ...{} )

o Return one mapping per group, with the following keys:

  - 'id' 

Definition at line 155 of file ZODBGroupManager.py.

00155 
00156     def listGroupInfo( self ):
00157 
00158         """ -> ( {}, ...{} )
00159 
00160         o Return one mapping per group, with the following keys:
00161 
00162           - 'id' 
00163         """
00164         return self._groups.values()

def PluggableAuthService.plugins.ZODBGroupManager.ZODBGroupManager.manage_addGroup (   self,
  group_id,
  title = None,
  description = None,
  RESPONSE = None 
)
Add a group via the ZMI.

Definition at line 345 of file ZODBGroupManager.py.

00345 
00346                        ):
00347         """ Add a group via the ZMI.
00348         """
00349         self.addGroup( group_id, title, description )
00350 
00351         message = 'Group+added'
00352 
00353         if RESPONSE is not None:
00354             RESPONSE.redirect( '%s/manage_groups?manage_tabs_message=%s'
00355                              % ( self.absolute_url(), message )
00356                              )

Here is the call graph for this function:

def PluggableAuthService.plugins.ZODBGroupManager.ZODBGroupManager.manage_addPrincipalsToGroup (   self,
  group_id,
  principal_ids,
  RESPONSE = None,
  REQUEST = None 
)
Add one or more principals to a group via the ZMI.

Definition at line 407 of file ZODBGroupManager.py.

00407 
00408                                    ):
00409         """ Add one or more principals to a group via the ZMI.
00410         """
00411         assigned = []
00412 
00413         for principal_id in principal_ids:
00414             if self.addPrincipalToGroup( principal_id, group_id ):
00415                 assigned.append( principal_id )
00416 
00417         if not assigned:
00418             message = 'Principals+already+members+of+%s' % group_id
00419         else:
00420             message = '%s+added+to+%s' % ( '+'.join( assigned )
00421                                          , group_id
00422                                          )
00423 
00424         if RESPONSE is not None:
00425             RESPONSE.redirect( ( '%s/manage_groups?group_id=%s&assign=1'
00426                                + '&manage_tabs_message=%s'
00427                                ) % ( self.absolute_url(), group_id, message )
                             )

Here is the call graph for this function:

def PluggableAuthService.plugins.ZODBGroupManager.ZODBGroupManager.manage_removeGroups (   self,
  group_ids,
  RESPONSE = None,
  REQUEST = None 
)
Remove one or more groups via the ZMI.

Definition at line 380 of file ZODBGroupManager.py.

00380 
00381                            ):
00382         """ Remove one or more groups via the ZMI.
00383         """
00384         group_ids = filter( None, group_ids )
00385 
00386         if not group_ids:
00387             message = 'no+groups+selected'
00388 
00389         else:
00390 
00391             for group_id in group_ids:
00392                 self.removeGroup( group_id )
00393 
00394             message = 'Groups+removed'
00395 
00396         if RESPONSE is not None:
00397             RESPONSE.redirect( '%s/manage_groups?manage_tabs_message=%s'
00398                              % ( self.absolute_url(), message )
                             )

Here is the call graph for this function:

def PluggableAuthService.plugins.ZODBGroupManager.ZODBGroupManager.manage_removePrincipalsFromGroup (   self,
  group_id,
  principal_ids,
  RESPONSE = None,
  REQUEST = None 
)
Remove one or more principals from a group via the ZMI.

Definition at line 438 of file ZODBGroupManager.py.

00438 
00439                                         ):
00440         """ Remove one or more principals from a group via the ZMI.
00441         """
00442         removed = []
00443 
00444         for principal_id in principal_ids:
00445             if self.removePrincipalFromGroup( principal_id, group_id ):
00446                 removed.append( principal_id )
00447 
00448         if not removed:
00449             message = 'Principals+not+in+group+%s' % group_id
00450         else:
00451             message = 'Principals+%s+removed+from+%s' % ( '+'.join( removed )
00452                                                         , group_id
00453                                                         )
00454 
00455         if RESPONSE is not None:
00456             RESPONSE.redirect( ( '%s/manage_groups?group_id=%s&assign=1'
00457                                + '&manage_tabs_message=%s'
00458                                ) % ( self.absolute_url(), group_id, message )
                             )

Here is the call graph for this function:

def PluggableAuthService.plugins.ZODBGroupManager.ZODBGroupManager.manage_updateGroup (   self,
  group_id,
  title,
  description,
  RESPONSE = None 
)
Update a group via the ZMI.

Definition at line 363 of file ZODBGroupManager.py.

00363 
00364                           ):
00365         """ Update a group via the ZMI.
00366         """
00367         self.updateGroup( group_id, title, description )
00368 
00369         message = 'Group+updated'
00370 
00371         if RESPONSE is not None:
00372             RESPONSE.redirect( '%s/manage_groups?manage_tabs_message=%s'
00373                              % ( self.absolute_url(), message )
00374                              )

Here is the call graph for this function:

Here is the caller graph for this function:

Remove 'role_id' from the list of roles managed by this
    object, removing assigned members from it before doing so.

o Raise KeyError if 'group_id' doesn't already exist.

Definition at line 200 of file ZODBGroupManager.py.

00200 
00201     def removeGroup( self, group_id ):
00202 
00203         """ Remove 'role_id' from the list of roles managed by this
00204             object, removing assigned members from it before doing so.
00205 
00206         o Raise KeyError if 'group_id' doesn't already exist.
00207         """
00208         for principal_id in self._principal_groups.keys():
00209             self.removePrincipalFromGroup( principal_id, group_id )
00210         del self._groups[ group_id ]

Here is the caller graph for this function:

def PluggableAuthService.plugins.ZODBGroupManager.ZODBGroupManager.removePrincipalFromGroup (   self,
  principal_id,
  group_id,
  REQUEST = None 
)
Remove a prinicpal from from a group.

o Return a boolean indicating whether the principal was already 
  a member of the group.

o Raise KeyError if 'group_id' is unknown.

o Ignore requests to remove a principal if not already a member
  of the group.

Definition at line 287 of file ZODBGroupManager.py.

00287 
00288     def removePrincipalFromGroup( self, principal_id, group_id, REQUEST=None ):
00289 
00290         """ Remove a prinicpal from from a group.
00291 
00292         o Return a boolean indicating whether the principal was already 
00293           a member of the group.
00294 
00295         o Raise KeyError if 'group_id' is unknown.
00296 
00297         o Ignore requests to remove a principal if not already a member
00298           of the group.
00299         """
00300         group_info = self._groups[ group_id ] # raise KeyError if unknown!
00301 
00302         current = self._principal_groups.get( principal_id, () )
00303         new = tuple( [ x for x in current if x != group_id ] )
00304         already = current != new
00305 
00306         if already:
00307             self._principal_groups[ principal_id ] = new
00308 
        return already

Here is the caller graph for this function:

def PluggableAuthService.plugins.ZODBGroupManager.ZODBGroupManager.updateGroup (   self,
  group_id,
  title,
  description 
)
Update properties for 'group_id'

o Raise KeyError if group_id doesn't already exist.

Definition at line 188 of file ZODBGroupManager.py.

00188 
00189     def updateGroup( self, group_id, title, description ):
00190 
00191         """ Update properties for 'group_id'
00192 
00193         o Raise KeyError if group_id doesn't already exist.
00194         """
00195         self._groups[ group_id ].update({ 'title' : title
00196                                         , 'description' : description
00197                                         })
00198         self._groups[ group_id ] = self._groups[ group_id ]

Here is the caller graph for this function:


Member Data Documentation

Definition at line 70 of file ZODBGroupManager.py.

Definition at line 68 of file ZODBGroupManager.py.

Definition at line 71 of file ZODBGroupManager.py.

Definition at line 284 of file ZODBGroupManager.py.

Definition at line 68 of file ZODBGroupManager.py.

Definition at line 428 of file ZODBGroupManager.py.

Initial value:
PageTemplateFile( 'www/zgGroups'
                                    , globals()
                                    , __name__='manage_groups'
                                    )

Definition at line 328 of file ZODBGroupManager.py.

Initial value:
( ( { 'label': 'Groups', 
                           'action': 'manage_groups', }
                         ,
                       )
                     + BasePlugin.manage_options
                     )

Definition at line 314 of file ZODBGroupManager.py.

Definition at line 399 of file ZODBGroupManager.py.

Definition at line 459 of file ZODBGroupManager.py.

Initial value:
PageTemplateFile( '../www/two_lists'
                                      , globals()
                                      , __name__='manage_twoLists'
                                      )

Definition at line 334 of file ZODBGroupManager.py.

Initial value:
PageTemplateFile( 'www/zuWidgets'
                                     , globals()
                                     , __name__='manage_widgets'
                                     )

Definition at line 322 of file ZODBGroupManager.py.

Definition at line 62 of file ZODBGroupManager.py.

Definition at line 309 of file ZODBGroupManager.py.

Definition at line 64 of file ZODBGroupManager.py.

Definition at line 69 of file ZODBGroupManager.py.


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