Back to index

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

List of all members.

Public Member Functions

def __init__
def getGroupsForPrincipal
def enumerateGroups
def listGroupIds
def getGroupInfo
def listGroupInfo
def addGroup
def updateGroup
def removeGroup
def manage_addGroup
def manage_updateGroup
def manage_removeGroups

Public Attributes

 title

Static Public Attributes

string meta_type = 'Dynamic Groups Plugin'
tuple security = ClassSecurityInfo()
tuple removeGroup = postonly(removeGroup)
tuple manage_options
tuple manage_groups
tuple manage_removeGroups = postonly(manage_removeGroups)

Detailed Description

Define groups via business rules.

o Membership in a candidate group is established via a predicate,
  expressed as a TALES expression.  Names available to the predicate
  include:

  'group' -- the dynamic group definition object itself

  'plugin' -- this plugin object

  'principal' -- the principal being tested.

  'request' -- the request object.

Definition at line 169 of file DynamicGroupsPlugin.py.


Constructor & Destructor Documentation

Definition at line 189 of file DynamicGroupsPlugin.py.

00189 
00190     def __init__( self, id, title='' ):
00191 
00192         self._setId( id )
00193         self.title = title

Here is the call graph for this function:


Member Function Documentation

def PluggableAuthService.plugins.DynamicGroupsPlugin.DynamicGroupsPlugin.addGroup (   self,
  group_id,
  predicate,
  title = '',
  description = '',
  active = True 
)
Add a group definition.

o Raise KeyError if we have an existing group definition
  for 'group_id'.

Definition at line 341 of file DynamicGroupsPlugin.py.

00341 
00342                 ):
00343 
00344         """ Add a group definition.
00345 
00346         o Raise KeyError if we have an existing group definition
00347           for 'group_id'.
00348         """
00349         if group_id in self.listGroupIds():
00350             raise KeyError, 'Duplicate group ID: %s' % group_id
00351 
00352         info = DynamicGroupDefinition( group_id
00353                                      , predicate
00354                                      , title
00355                                      , description
00356                                      , active
00357                                      )
00358 
00359         self._setObject( group_id, info )
00360 
00361         # This method changes the enumerateGroups return value
00362         view_name = createViewName('enumerateGroups')
00363         self.ZCacheable_invalidate(view_name=view_name)
            

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 216 of file DynamicGroupsPlugin.py.

00216 
00217                        ):
00218         """ See IGroupEnumerationPlugin.
00219         """
00220         group_info = []
00221         group_ids = []
00222         plugin_id = self.getId()
00223         view_name = createViewName('enumerateGroups', id)
00224 
00225         # Look in the cache first...
00226         keywords = copy.deepcopy(kw)
00227         keywords.update( { 'id' : id
00228                          , 'exact_match' : exact_match
00229                          , 'sort_by' : sort_by
00230                          , 'max_results' : max_results
00231                          }
00232                        )
00233         cached_info = self.ZCacheable_get( view_name=view_name
00234                                          , keywords=keywords
00235                                          , default=None
00236                                          )
00237 
00238         if cached_info is not None:
00239             return tuple(cached_info)
00240 
00241         if isinstance( id, str ):
00242             id = [ id ]
00243 
00244         if exact_match and id:
00245             group_ids.extend( id )
00246 
00247         if group_ids:
00248             group_filter = None
00249 
00250         else:   # Searching
00251             group_ids = self.listGroupIds()
00252             group_filter = _DynamicGroupFilter( id, **kw )
00253 
00254         for group_id in group_ids:
00255 
00256             url = '/%s/%s/manage_propertiesForm' % ( self.absolute_url( 1 )
00257                                                    , group_id )
00258             info = {}
00259             info.update( self.getGroupInfo( group_id ) )
00260 
00261             info[ 'pluginid' ] = plugin_id
00262             info[ 'properties_url' ] = url
00263             info[ 'members_url' ] = url
00264 
00265             info[ 'id' ] = '%s%s' % (self.prefix, info['id'])
00266 
00267             if not group_filter or group_filter( info ):
00268                 if info[ 'active' ]:
00269                     group_info.append( info )
00270 
00271         # Put the computed value into the cache
00272         self.ZCacheable_set(group_info, view_name=view_name, keywords=keywords)
00273 
00274         return tuple( group_info )

Here is the caller graph for this function:

Return a mappings describing one dynamic group we manage.

o Raise KeyError if we don't have an existing group definition
  for 'group_ id'.

o Keys include:

  'id' -- the group's ID

  'predicate' -- the TALES expression defining group membership

  'active' -- boolean flag:  is the group currently active?

Definition at line 286 of file DynamicGroupsPlugin.py.

00286 
00287     def getGroupInfo( self, group_id ):
00288 
00289         """ Return a mappings describing one dynamic group we manage.
00290 
00291         o Raise KeyError if we don't have an existing group definition
00292           for 'group_ id'.
00293 
00294         o Keys include:
00295 
00296           'id' -- the group's ID
00297 
00298           'predicate' -- the TALES expression defining group membership
00299 
00300           'active' -- boolean flag:  is the group currently active?
00301         """
00302         try:
00303             original = self._getOb( group_id )
00304         except AttributeError:
00305             try:
00306                 original = self._getOb( group_id[len(self.prefix):] )
00307             except AttributeError:
00308                 raise KeyError, group_id
00309 
00310         if not isinstance( original, DynamicGroupDefinition ):
00311             raise KeyError, group_id
00312 
00313         info = {}
00314 
00315         for k, v in original.propertyItems():
00316             info[ k ] = v
00317 
00318         return info

Here is the call graph for this function:

Here is the caller graph for this function:

See IGroupsPlugin.

Definition at line 198 of file DynamicGroupsPlugin.py.

00198 
00199     def getGroupsForPrincipal( self, principal, request=None ):
00200 
00201         """ See IGroupsPlugin.
00202         """
00203         grps = []
00204         DGD = DynamicGroupDefinition.meta_type
00205         for group in self.objectValues( DGD ):
00206             if group.active and group( principal, request ):
00207                 grps.append('%s%s' % (self.prefix, group.getId()))
00208         return grps

Here is the call graph for this function:

Return a list of IDs for the dynamic groups we manage.

Definition at line 279 of file DynamicGroupsPlugin.py.

00279 
00280     def listGroupIds( self ):
00281 
00282         """ Return a list of IDs for the dynamic groups we manage.
00283         """
00284         return self.objectIds( DynamicGroupDefinition.meta_type )

Here is the call graph for this function:

Here is the caller graph for this function:

Return a list of mappings describing the dynamic groups we manage.

o Keys include:

  'id' -- the group's ID

  'predicate' -- the TALES expression defining group membership

  'active' -- boolean flag:  is the group currently active?

Definition at line 320 of file DynamicGroupsPlugin.py.

00320 
00321     def listGroupInfo( self ):
00322 
00323         """ Return a list of mappings describing the dynamic groups we manage.
00324 
00325         o Keys include:
00326 
00327           'id' -- the group's ID
00328 
00329           'predicate' -- the TALES expression defining group membership
00330 
00331           'active' -- boolean flag:  is the group currently active?
00332         """
00333         return [ self.getGroupInfo( x ) for x in self.listGroupIds() ]

Here is the call graph for this function:

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

Definition at line 449 of file DynamicGroupsPlugin.py.

00449 
00450                        ):
00451         """ Add a group via the ZMI.
00452         """
00453         self.addGroup( group_id
00454                      , predicate
00455                      , title
00456                      , description
00457                      , active
00458                      )
00459 
00460         message = 'Group+%s+added' % group_id
00461 
00462         if RESPONSE is not None:
00463             RESPONSE.redirect( '%s/manage_groups?manage_tabs_message=%s'
00464                             % ( self.absolute_url(), message )
00465                             )

Here is the call graph for this function:

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

Definition at line 497 of file DynamicGroupsPlugin.py.

00497 
00498                            ):
00499         """ Remove one or more groups via the ZMI.
00500         """
00501         group_ids = filter( None, group_ids )
00502 
00503         if not group_ids:
00504             message = 'no+groups+selected'
00505 
00506         else:
00507         
00508             for group_id in group_ids:
00509                 self.removeGroup( group_id )
00510 
00511             message = 'Groups+removed'
00512 
00513         if RESPONSE is not None:
00514             RESPONSE.redirect( '%s/manage_groups?manage_tabs_message=%s'
00515                              % ( self.absolute_url(), message )
                             )

Here is the call graph for this function:

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

Definition at line 474 of file DynamicGroupsPlugin.py.

00474 
00475                           ):
00476         """ Update a group via the ZMI.
00477         """
00478         self.updateGroup( group_id
00479                         , predicate
00480                         , title
00481                         , description
00482                         , active
00483                         )
00484 
00485         message = 'Group+%s+updated' % group_id
00486 
00487         if RESPONSE is not None:
00488             RESPONSE.redirect( ( '%s/manage_groups?group_id=%s&'
00489                                + 'manage_tabs_message=%s'
00490                                ) % ( self.absolute_url(), group_id, message )
00491                              )

Here is the call graph for this function:

Here is the caller graph for this function:

Remove a group definition.

o Raise KeyError if we don't have an existing group definition
  for 'group_id'.

Definition at line 403 of file DynamicGroupsPlugin.py.

00403 
00404     def removeGroup( self, group_id, REQUEST=None ):
00405 
00406         """ Remove a group definition.
00407 
00408         o Raise KeyError if we don't have an existing group definition
00409           for 'group_id'.
00410         """
00411         if group_id not in self.listGroupIds():
00412             raise KeyError, 'Invalid group ID: %s' % group_id
00413 
00414         self._delObject( group_id )
00415 
00416         # This method changes the enumerateGroups return value
00417         view_name = createViewName('enumerateGroups')
00418         self.ZCacheable_invalidate(view_name=view_name)
00419         view_name = createViewName('enumerateGroups', group_id)
        self.ZCacheable_invalidate(view_name=view_name)

Here is the call graph for this function:

Here is the caller graph for this function:

def PluggableAuthService.plugins.DynamicGroupsPlugin.DynamicGroupsPlugin.updateGroup (   self,
  group_id,
  predicate,
  title = None,
  description = None,
  active = None 
)
Update a group definition.

o Raise KeyError if we don't have an existing group definition
  for 'group_id'.

o Don't update 'title', 'description', or 'active' unless supplied.

Definition at line 371 of file DynamicGroupsPlugin.py.

00371 
00372                    ):
00373 
00374         """ Update a group definition.
00375 
00376         o Raise KeyError if we don't have an existing group definition
00377           for 'group_id'.
00378 
00379         o Don't update 'title', 'description', or 'active' unless supplied.
00380         """
00381         if group_id not in self.listGroupIds():
00382             raise KeyError, 'Invalid group ID: %s' % group_id
00383 
00384         group = self._getOb( group_id )
00385 
00386         group._setPredicate( predicate )
00387 
00388         if title is not None:
00389             group.title = title
00390 
00391         if description is not None:
00392             group.description = description
00393 
00394         if active is not None:
00395             group.active = active
00396 
00397         # This method changes the enumerateGroups return value
00398         view_name = createViewName('enumerateGroups')
00399         self.ZCacheable_invalidate(view_name=view_name)
00400         view_name = createViewName('enumerateGroups', group_id)
00401         self.ZCacheable_invalidate(view_name=view_name)
            

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

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

Definition at line 436 of file DynamicGroupsPlugin.py.

Initial value:
( ( { 'label' : 'Groups'
                         , 'action' : 'manage_groups'
                         }
                       ,
                       )
                     + Folder.manage_options[:1]
                     + BasePlugin.manage_options[:1]
                     + Folder.manage_options[1:]
                     + Cacheable.manage_options
                     )

Definition at line 425 of file DynamicGroupsPlugin.py.

Definition at line 516 of file DynamicGroupsPlugin.py.

Definition at line 185 of file DynamicGroupsPlugin.py.

Definition at line 420 of file DynamicGroupsPlugin.py.

Definition at line 187 of file DynamicGroupsPlugin.py.

Definition at line 192 of file DynamicGroupsPlugin.py.


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