Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes
CMFCore.ActionProviderBase.ActionProviderBase Class Reference

List of all members.

Public Member Functions

def listActions
def getActionObject
def listActionInfos
def getActionInfo
def manage_editActionsForm
def addAction
def changeActions
def deleteActions
def moveUpActions
def moveDownActions

Static Public Attributes

tuple security = ClassSecurityInfo()
tuple manage_options

Private Member Functions

def _cloneActions
def _extractAction
def _getOAI
def _getExprContext

Private Attributes

 _actions

Static Private Attributes

 __implements__ = z2IActionProvider
tuple _actions = ()
tuple _actions_form = DTMLFile( 'editToolsActions', _dtmldir )

Detailed Description

Provide ActionTabs and management methods for ActionProviders

Definition at line 34 of file ActionProviderBase.py.


Member Function Documentation

Return a list of actions, cloned from our current list.

Definition at line 303 of file ActionProviderBase.py.

00303 
00304     def _cloneActions( self ):
00305 
00306         """ Return a list of actions, cloned from our current list.
00307         """
00308         return map( lambda x: x.clone(), list( self._actions ) )

Here is the caller graph for this function:

def CMFCore.ActionProviderBase.ActionProviderBase._extractAction (   self,
  properties,
  index 
) [private]
Extract an ActionInformation from the funky form properties.

Definition at line 310 of file ActionProviderBase.py.

00310 
00311     def _extractAction( self, properties, index ):
00312 
00313         """ Extract an ActionInformation from the funky form properties.
00314         """
00315         id          = str( properties.get( 'id_%d'          % index, '' ) )
00316         title       = str( properties.get( 'name_%d'        % index, '' ) )
00317         action      = str( properties.get( 'action_%d'      % index, '' ) )
00318         condition   = str( properties.get( 'condition_%d'   % index, '' ) )
00319         category    = str( properties.get( 'category_%d'    % index, '' ))
00320         visible     = bool( properties.get('visible_%d'     % index, False) )
00321         permissions =      properties.get( 'permission_%d'  % index, () )
00322 
00323         if not title:
00324             raise ValueError('A title is required.')
00325 
00326         if category == '':
00327             category = 'object'
00328 
00329         if isinstance(permissions, basestring):
00330             permissions = ( permissions, )
00331 
00332         return ActionInformation( id=id
00333                                 , title=title
00334                                 , action=action
00335                                 , condition=condition
00336                                 , permissions=permissions
00337                                 , category=category
00338                                 , visible=visible
00339                                 )

Here is the caller graph for this function:

def CMFCore.ActionProviderBase.ActionProviderBase._getExprContext (   self,
  object 
) [private]

Definition at line 343 of file ActionProviderBase.py.

00343 
00344     def _getExprContext(self, object):
00345         return getExprContext(self, object)
00346 
00347 InitializeClass(ActionProviderBase)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.ActionProviderBase.ActionProviderBase._getOAI (   self,
  object 
) [private]

Definition at line 340 of file ActionProviderBase.py.

00340 
00341     def _getOAI(self, object):
00342         return getOAI(self, object)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.ActionProviderBase.ActionProviderBase.addAction (   self,
  id,
  name,
  action,
  condition,
  permission,
  category,
  visible = 1,
  REQUEST = None 
)
Add an action to our list.

Definition at line 174 of file ActionProviderBase.py.

00174 
00175                  ):
00176         """ Add an action to our list.
00177         """
00178         if not name:
00179             raise ValueError('A name is required.')
00180 
00181         action = action and str(action) or ''
00182         condition = condition and str(condition) or ''
00183 
00184         if not isinstance(permission, tuple):
00185             permission = (str(permission),)
00186 
00187         new_actions = self._cloneActions()
00188 
00189         new_action = ActionInformation( id=str(id)
00190                                       , title=str(name)
00191                                       , category=str(category)
00192                                       , condition=condition
00193                                       , permissions=permission
00194                                       , visible=bool(visible)
00195                                       , action=action
00196                                       )
00197 
00198         new_actions.append( new_action )
00199         self._actions = tuple( new_actions )
00200 
00201         if REQUEST is not None:
00202             return self.manage_editActionsForm(
00203                 REQUEST, manage_tabs_message='Added.')

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.ActionProviderBase.ActionProviderBase.changeActions (   self,
  properties = None,
  REQUEST = None 
)
Update our list of actions.

Definition at line 205 of file ActionProviderBase.py.

00205 
00206     def changeActions( self, properties=None, REQUEST=None ):
00207 
00208         """ Update our list of actions.
00209         """
00210         if properties is None:
00211             properties = REQUEST
00212 
00213         actions = []
00214 
00215         for index in range( len( self._actions ) ):
00216             actions.append( self._extractAction( properties, index ) )
00217 
00218         self._actions = tuple( actions )
00219 
00220         if REQUEST is not None:
00221             return self.manage_editActionsForm(REQUEST, manage_tabs_message=
00222                                                'Actions changed.')

Here is the call graph for this function:

def CMFCore.ActionProviderBase.ActionProviderBase.deleteActions (   self,
  selections = (),
  REQUEST = None 
)
Delete actions indicated by indexes in 'selections'.

Definition at line 224 of file ActionProviderBase.py.

00224 
00225     def deleteActions( self, selections=(), REQUEST=None ):
00226 
00227         """ Delete actions indicated by indexes in 'selections'.
00228         """
00229         sels = list( map( int, selections ) )  # Convert to a list of integers.
00230 
00231         old_actions = self._cloneActions()
00232         new_actions = []
00233 
00234         for index in range( len( old_actions ) ):
00235             if index not in sels:
00236                 new_actions.append( old_actions[ index ] )
00237 
00238         self._actions = tuple( new_actions )
00239 
00240         if REQUEST is not None:
00241             return self.manage_editActionsForm(
00242                 REQUEST, manage_tabs_message=(
00243                 'Deleted %d action(s).' % len(sels)))

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.ActionProviderBase.ActionProviderBase.getActionInfo (   self,
  action_chain,
  object = None,
  check_visibility = 0,
  check_condition = 0 
)
Get an ActionInfo object specified by a chain of actions.

Definition at line 123 of file ActionProviderBase.py.

00123 
00124                       check_condition=0):
00125         """ Get an ActionInfo object specified by a chain of actions.
00126         """
00127         action_infos = self.listActionInfos(action_chain, object,
00128                                             check_visibility=check_visibility,
00129                                             check_permissions=False,
00130                                             check_condition=check_condition)
00131         if not action_infos:
00132             if object is None:
00133                 provider = self
00134             else:
00135                 provider = object
00136             msg = 'Action "%s" not available for %s' % (
00137                         action_chain, '/'.join(provider.getPhysicalPath()))
00138             raise ValueError(msg)
00139         for ai in action_infos:
00140             if ai['allowed']:
00141                 return ai
00142         raise AccessControl_Unauthorized('You are not allowed to access any '
00143                                          'of the specified Actions.')

Here is the call graph for this function:

Here is the caller graph for this function:

Return the actions object or None if action doesn't exist.

Definition at line 65 of file ActionProviderBase.py.

00065 
00066     def getActionObject(self, action):
00067         """Return the actions object or None if action doesn't exist.
00068         """
00069         # separate cataegory and id from action
00070         sep = action.rfind('/')
00071         if sep == -1:
00072             raise ValueError('Actions must have the format <category>/<id>.')
00073         category, id = action[:sep], action[sep+1:]
00074 
00075         # search for action and return first one found
00076         for ai in self.listActions():
00077             try:
00078                 if id == ai.getId() and category == ai.getCategory():
00079                     return ai
00080             except AttributeError:
00081                 continue
00082 
00083         # no action found
00084         return None

Here is the call graph for this function:

def CMFCore.ActionProviderBase.ActionProviderBase.listActionInfos (   self,
  action_chain = None,
  object = None,
  check_visibility = 1,
  check_permissions = 1,
  check_condition = 1,
  max = -1 
)

Definition at line 88 of file ActionProviderBase.py.

00088 
00089                         check_condition=1, max=-1):
00090         # List ActionInfo objects.
00091         # (method is without docstring to disable publishing)
00092         #
00093         ec = self._getExprContext(object)
00094         actions = self.listActions(object=object)
00095         actions = [ ActionInfo(action, ec) for action in actions ]
00096 
00097         if action_chain:
00098             filtered_actions = []
00099             if isinstance(action_chain, basestring):
00100                 action_chain = (action_chain,)
00101             for action_ident in action_chain:
00102                 sep = action_ident.rfind('/')
00103                 category, id = action_ident[:sep], action_ident[sep+1:]
00104                 for ai in actions:
00105                     if id == ai['id'] and category == ai['category']:
00106                         filtered_actions.append(ai)
00107             actions = filtered_actions
00108 
00109         action_infos = []
00110         for ai in actions:
00111             if check_visibility and not ai['visible']:
00112                 continue
00113             if check_permissions and not ai['allowed']:
00114                 continue
00115             if check_condition and not ai['available']:
00116                 continue
00117             action_infos.append(ai)
00118             if max + 1 and len(action_infos) >= max:
00119                 break
00120         return action_infos

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.ActionProviderBase.ActionProviderBase.listActions (   self,
  info = None,
  object = None 
)
List all the actions defined by a provider.

Definition at line 59 of file ActionProviderBase.py.

00059 
00060     def listActions(self, info=None, object=None):
00061         """ List all the actions defined by a provider.
00062         """
00063         return self._actions or ()

Here is the caller graph for this function:

def CMFCore.ActionProviderBase.ActionProviderBase.manage_editActionsForm (   self,
  REQUEST,
  manage_tabs_message = None 
)
Show the 'Actions' management tab.

Definition at line 148 of file ActionProviderBase.py.

00148 
00149     def manage_editActionsForm( self, REQUEST, manage_tabs_message=None ):
00150 
00151         """ Show the 'Actions' management tab.
00152         """
00153         actions = [ ai.getMapping() for ai in self.listActions() ]
00154 
00155         # possible_permissions is in AccessControl.Role.RoleManager.
00156         pp = self.possible_permissions()
00157         return self._actions_form( self
00158                                  , REQUEST
00159                                  , actions=actions
00160                                  , possible_permissions=pp
00161                                  , management_view='Actions'
00162                                  , manage_tabs_message=manage_tabs_message
00163                                  )

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.ActionProviderBase.ActionProviderBase.moveDownActions (   self,
  selections = (),
  REQUEST = None 
)
Move the specified actions down one slot in our list.

Definition at line 272 of file ActionProviderBase.py.

00272 
00273     def moveDownActions( self, selections=(), REQUEST=None ):
00274 
00275         """ Move the specified actions down one slot in our list.
00276         """
00277         sels = list( map( int, selections ) )  # Convert to a list of integers.
00278         sels.sort()
00279         sels.reverse()
00280 
00281         new_actions = self._cloneActions()
00282 
00283         for idx in sels:
00284             idx2 = idx + 1
00285             if idx2 >= len(new_actions):
00286                 # Wrap to the top.
00287                 idx2 = 0
00288             # Swap.
00289             a = new_actions[idx2]
00290             new_actions[idx2] = new_actions[idx]
00291             new_actions[idx] = a
00292 
00293         self._actions = tuple( new_actions )
00294 
00295         if REQUEST is not None:
00296             return self.manage_editActionsForm(
00297                 REQUEST, manage_tabs_message=(
00298                 'Moved down %d action(s).' % len(sels)))

Here is the call graph for this function:

def CMFCore.ActionProviderBase.ActionProviderBase.moveUpActions (   self,
  selections = (),
  REQUEST = None 
)
Move the specified actions up one slot in our list.

Definition at line 245 of file ActionProviderBase.py.

00245 
00246     def moveUpActions( self, selections=(), REQUEST=None ):
00247 
00248         """ Move the specified actions up one slot in our list.
00249         """
00250         sels = list( map( int, selections ) )  # Convert to a list of integers.
00251         sels.sort()
00252 
00253         new_actions = self._cloneActions()
00254 
00255         for idx in sels:
00256             idx2 = idx - 1
00257             if idx2 < 0:
00258                 # Wrap to the bottom.
00259                 idx2 = len(new_actions) - 1
00260             # Swap.
00261             a = new_actions[idx2]
00262             new_actions[idx2] = new_actions[idx]
00263             new_actions[idx] = a
00264 
00265         self._actions = tuple( new_actions )
00266 
00267         if REQUEST is not None:
00268             return self.manage_editActionsForm(
00269                 REQUEST, manage_tabs_message=(
00270                 'Moved up %d action(s).' % len(sels)))

Here is the call graph for this function:


Member Data Documentation

CMFCore.ActionProviderBase.ActionProviderBase.__implements__ = z2IActionProvider [static, private]

Definition at line 40 of file ActionProviderBase.py.

Definition at line 44 of file ActionProviderBase.py.

Definition at line 198 of file ActionProviderBase.py.

tuple CMFCore.ActionProviderBase.ActionProviderBase._actions_form = DTMLFile( 'editToolsActions', _dtmldir ) [static, private]

Definition at line 46 of file ActionProviderBase.py.

Initial value:
( { 'label'  : 'Actions'
                       , 'action' : 'manage_editActionsForm'
                       , 'help'   : ('CMFCore', 'Actions.stx')
                       }
                     ,
                     )

Definition at line 48 of file ActionProviderBase.py.

tuple CMFCore.ActionProviderBase.ActionProviderBase.security = ClassSecurityInfo() [static]

Definition at line 42 of file ActionProviderBase.py.


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