Back to index

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

List of all members.

Public Member Functions

def __init__
def listActionIcons
def getActionInfo
def queryActionInfo
def getActionIcon
def queryActionIcon
def updateActionDicts
def addActionIcon
def updateActionIcon
def removeActionIcon
def clearActionIcons
def manage_addActionIcon
def manage_updateActionIcon
def manage_removeActionIcon

Static Public Attributes

string meta_type = 'Action Icons Tool'
string id = 'portal_actionicons'
tuple security = ClassSecurityInfo()
tuple manage_options
tuple manage_editActionIcons = PageTemplateFile( 'aitEdit', _wwwdir )

Private Attributes

 _icons
 _lookup

Static Private Attributes

 __call__ = updateActionDicts

Detailed Description

Map actions only icons.

Definition at line 115 of file ActionIconsTool.py.


Constructor & Destructor Documentation

Definition at line 128 of file ActionIconsTool.py.

00128 
00129     def __init__( self ):
00130 
00131         self.clearActionIcons()

Here is the call graph for this function:


Member Function Documentation

def CMFActionIcons.ActionIconsTool.ActionIconsTool.addActionIcon (   self,
  category,
  action_id,
  icon_expr,
  title = None,
  priority = 0 
)
Add an icon for the given action.

o Raise KeyError if an icon has already been defined.

Definition at line 283 of file ActionIconsTool.py.

00283 
00284                      ):
00285 
00286         """ Add an icon for the given action.
00287 
00288         o Raise KeyError if an icon has already been defined.
00289         """
00290         if self.queryActionInfo( category, action_id ) is not None:
00291             raise KeyError, 'Duplicate definition!'
00292 
00293         icons = list( self._icons )
00294         icons.append( ActionIcon( category
00295                                 , action_id
00296                                 , icon_expr
00297                                 , title
00298                                 , priority
00299                                 ) )
00300         self._lookup[ ( category, action_id ) ] = icons[-1]
00301         self._icons = tuple( icons )

Here is the call graph for this function:

Here is the caller graph for this function:

Remove all mappings from the tool.

Definition at line 349 of file ActionIconsTool.py.

00349 
00350     def clearActionIcons( self ):
00351 
00352         """ Remove all mappings from the tool.
00353         """
00354         self._icons = ()
00355         self._lookup = {}

Here is the caller graph for this function:

def CMFActionIcons.ActionIconsTool.ActionIconsTool.getActionIcon (   self,
  category,
  action_id,
  context = None 
)
Return an icon ID for the given action.

o Raise a KeyError if no icon has been defined for the action.

o Context is an Expression context object, used to evaluate
  TALES expressions.

Definition at line 182 of file ActionIconsTool.py.

00182 
00183     def getActionIcon( self, category, action_id, context=None ):
00184 
00185         """ Return an icon ID for the given action.
00186 
00187         o Raise a KeyError if no icon has been defined for the action.
00188 
00189         o Context is an Expression context object, used to evaluate
00190           TALES expressions.
00191         """
00192         return self._lookup[ ( category, action_id ) ].getIconURL( context )

Here is the call graph for this function:

def CMFActionIcons.ActionIconsTool.ActionIconsTool.getActionInfo (   self,
  category,
  action_id,
  context = None 
)
Return a tuple, '(title, priority, icon ID), for the given action.

o Raise a KeyError if no icon has been defined for the action.

Definition at line 151 of file ActionIconsTool.py.

00151 
00152                      ):
00153 
00154         """ Return a tuple, '(title, priority, icon ID), for the given action.
00155 
00156         o Raise a KeyError if no icon has been defined for the action.
00157         """
00158         ai = self._lookup[ ( category, action_id ) ]
00159         return ( ai.getTitle()
00160                , ai.getPriority()
00161                , ai.getIconURL( context )
00162                )

Here is the call graph for this function:

Here is the caller graph for this function:

Return a sequence of mappings for action icons

o Mappings are in the form: ( category, action ) -> icon,
  where category and action are strings and icon is an ActionIcon
  instance.

Definition at line 136 of file ActionIconsTool.py.

00136 
00137     def listActionIcons( self ):
00138 
00139         """ Return a sequence of mappings for action icons
00140 
00141         o Mappings are in the form: ( category, action ) -> icon,
00142           where category and action are strings and icon is an ActionIcon
00143           instance.
00144         """
00145         return [ x.__of__( self ) for x in self._icons ]

Here is the call graph for this function:

def CMFActionIcons.ActionIconsTool.ActionIconsTool.manage_addActionIcon (   self,
  category,
  action_id,
  icon_expr,
  title,
  priority,
  REQUEST 
)
Add an icon for the given action via the ZMI.

Definition at line 376 of file ActionIconsTool.py.

00376 
00377                             ):
00378 
00379         """ Add an icon for the given action via the ZMI.
00380         """
00381         self.addActionIcon( category
00382                           , action_id
00383                           , icon_expr
00384                           , title
00385                           , priority
00386                           )
00387 
00388         REQUEST['RESPONSE'].redirect( '%s/manage_editActionIcons'
00389                                       '?manage_tabs_message=Action+added.'
00390                                     % self.absolute_url()
00391                                     )

Here is the call graph for this function:

def CMFActionIcons.ActionIconsTool.ActionIconsTool.manage_removeActionIcon (   self,
  category,
  action_id,
  REQUEST 
)
Remove the icon for the given action via the ZMI.

Definition at line 417 of file ActionIconsTool.py.

00417 
00418     def manage_removeActionIcon( self, category, action_id, REQUEST ):
00419 
00420         """ Remove the icon for the given action via the ZMI.
00421         """
00422         self.removeActionIcon( category, action_id )
00423 
00424         REQUEST['RESPONSE'].redirect( '%s/manage_editActionIcons'
00425                                       '?manage_tabs_message=Action+removed.'
00426                                     % self.absolute_url()
00427                                     )
00428 
00429 InitializeClass( ActionIconsTool )
00430 registerToolInterface('portal_actionicons', IActionIconsTool)

Here is the call graph for this function:

def CMFActionIcons.ActionIconsTool.ActionIconsTool.manage_updateActionIcon (   self,
  category,
  action_id,
  icon_expr,
  title,
  priority,
  REQUEST 
)
Update an icon for the given action via the ZMI.

Definition at line 400 of file ActionIconsTool.py.

00400 
00401                                ):
00402 
00403         """ Update an icon for the given action via the ZMI.
00404         """
00405         self.updateActionIcon( category
00406                              , action_id
00407                              , icon_expr
00408                              , title
00409                              , priority
00410                              )
00411 
00412         REQUEST['RESPONSE'].redirect( '%s/manage_editActionIcons'
00413                                       '?manage_tabs_message=Action+updated.'
00414                                     % self.absolute_url()
00415                                     )

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFActionIcons.ActionIconsTool.ActionIconsTool.queryActionIcon (   self,
  category,
  action_id,
  default = None,
  context = None 
)
Return an icon ID for the given action.

o Return 'default' if no icon has been defined for the action.

o Context is an Expression context object, used to evaluate
  TALES expressions.

Definition at line 195 of file ActionIconsTool.py.

00195 
00196                        , default=None, context=None ):
00197 
00198         """ Return an icon ID for the given action.
00199 
00200         o Return 'default' if no icon has been defined for the action.
00201 
00202         o Context is an Expression context object, used to evaluate
00203           TALES expressions.
00204         """
00205         ai = self._lookup.get( ( category, action_id ) )
00206         return ai and ai.getIconURL( context ) or default

Here is the caller graph for this function:

def CMFActionIcons.ActionIconsTool.ActionIconsTool.queryActionInfo (   self,
  category,
  action_id,
  default = None,
  context = None 
)
Return a tuple, '(title, priority, icon ID), for the given action.

o Return 'default' if no icon has been defined for the action.

Definition at line 169 of file ActionIconsTool.py.

00169 
00170                        ):
00171 
00172         """ Return a tuple, '(title, priority, icon ID), for the given action.
00173 
00174         o Return 'default' if no icon has been defined for the action.
00175         """
00176         ai = self._lookup.get( ( category, action_id ) )
00177         return ai and ( ai.getTitle()
00178                       , ai.getPriority()
00179                       , ai.getIconURL( context )
00180                       ) or default

Here is the caller graph for this function:

def CMFActionIcons.ActionIconsTool.ActionIconsTool.removeActionIcon (   self,
  category,
  action_id 
)
Remove the icon for the given action.

o Raise KeyError if an icon has not already been defined.

Definition at line 332 of file ActionIconsTool.py.

00332 
00333     def removeActionIcon( self, category, action_id ):
00334 
00335         """ Remove the icon for the given action.
00336 
00337         o Raise KeyError if an icon has not already been defined.
00338         """
00339         if self.queryActionInfo( category, action_id ) is None:
00340             raise KeyError, 'No such definition (%s, %s)!' % (
00341                 category, action_id)
00342 
00343         icons = list( self._icons )
00344         icon = self._lookup[ ( category, action_id ) ]
00345         icons.remove( icon )
00346         del self._lookup[ ( category, action_id ) ]
00347         self._icons = tuple( icons )

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFActionIcons.ActionIconsTool.ActionIconsTool.updateActionDicts (   self,
  categorized_actions,
  context = None 
)
Update a set of dictionaries, adding 'title, 'priority', and
    'icon' keys.

o S.b. passed a data structure like that returned from ActionsTool's
  'listFilteredActionsFor':

  - Dict mapping category -> seq. of dicts, where each of the
    leaf dicts must have 'category' and 'id' keys.

o *Will* overwrite the 'title' key, if title is defined on the tool.

o *Will* overwrite the 'priority' key.

o *Will* overwrite the 'icon' key, if icon is defined on the tool

o XXX:  Don't have a way to pass Expression context yet.

Definition at line 208 of file ActionIconsTool.py.

00208 
00209     def updateActionDicts( self, categorized_actions, context=None ):
00210 
00211         """ Update a set of dictionaries, adding 'title, 'priority', and
00212             'icon' keys.
00213 
00214         o S.b. passed a data structure like that returned from ActionsTool's
00215           'listFilteredActionsFor':
00216 
00217           - Dict mapping category -> seq. of dicts, where each of the
00218             leaf dicts must have 'category' and 'id' keys.
00219 
00220         o *Will* overwrite the 'title' key, if title is defined on the tool.
00221 
00222         o *Will* overwrite the 'priority' key.
00223 
00224         o *Will* overwrite the 'icon' key, if icon is defined on the tool
00225 
00226         o XXX:  Don't have a way to pass Expression context yet.
00227         """
00228         result = {}
00229 
00230         for category, actions in categorized_actions.items():
00231 
00232             new_actions = []
00233 
00234             for action in actions:
00235 
00236                 action = action.copy()
00237 
00238                 action_id = action.get( 'id' )
00239 
00240                 #  Hack around DCWorkflow's ID-less worklist actions.
00241                 if action_id is None and action.get( 'category' ) == 'workflow':
00242                     action[ 'id' ] = action_id = action.get( 'name' )
00243 
00244                 if action_id:
00245 
00246                     info = self.queryActionInfo( category
00247                                                , action_id
00248                                                , context=context
00249                                                )
00250                     if info is not None:
00251 
00252                         title, priority, icon = info
00253 
00254                         if title is not None:
00255                             action[ 'title' ] = title
00256 
00257                         if priority is not None:
00258                             action[ 'priority' ] = priority
00259 
00260                         if icon is not None:
00261                             action[ 'icon' ] = icon
00262 
00263                 new_actions.append( action )
00264 
00265             new_actions.sort( lambda x, y: cmp( x.get( 'priority', 0 )
00266                                               , y.get( 'priority', 0 )
00267                                               ) )
00268             result[ category ] = new_actions
00269 
00270         return result

Here is the call graph for this function:

def CMFActionIcons.ActionIconsTool.ActionIconsTool.updateActionIcon (   self,
  category,
  action_id,
  icon_expr,
  title = None,
  priority = 0 
)
Update the icon for the given action.

o Raise KeyError if an icon has not already been defined.

Definition at line 309 of file ActionIconsTool.py.

00309 
00310                         ):
00311 
00312         """ Update the icon for the given action.
00313 
00314         o Raise KeyError if an icon has not already been defined.
00315         """
00316         if self._lookup.get( ( category, action_id ) ) is None:
00317             raise KeyError, 'No such definition!'
00318 
00319         icons = list( self._icons )
00320         for ai in icons:
00321             if ( ai.getCategory() == category
00322              and ai.getActionId() == action_id
00323                ):
00324                 ai.updateIconExpression( icon_expr )
00325                 ai._title = title
00326                 ai._priority = priority
00327                 break
00328         else:
00329             raise KeyError, ( category, action_id )
00330         self._icons = tuple( icons )

Here is the caller graph for this function:


Member Data Documentation

Definition at line 271 of file ActionIconsTool.py.

Definition at line 300 of file ActionIconsTool.py.

Definition at line 354 of file ActionIconsTool.py.

string CMFActionIcons.ActionIconsTool.ActionIconsTool.id = 'portal_actionicons' [static]

Definition at line 123 of file ActionIconsTool.py.

tuple CMFActionIcons.ActionIconsTool.ActionIconsTool.manage_editActionIcons = PageTemplateFile( 'aitEdit', _wwwdir ) [static]

Definition at line 366 of file ActionIconsTool.py.

Initial value:
( { 'label' : 'Icons'
                        , 'action' : 'manage_editActionIcons'
                        }
                      ,
                      )

Definition at line 359 of file ActionIconsTool.py.

string CMFActionIcons.ActionIconsTool.ActionIconsTool.meta_type = 'Action Icons Tool' [static]

Definition at line 122 of file ActionIconsTool.py.

tuple CMFActionIcons.ActionIconsTool.ActionIconsTool.security = ClassSecurityInfo() [static]

Definition at line 125 of file ActionIconsTool.py.


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