Logo Search packages:      
Sourcecode: zope-cmfactionicons version File versions

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 201 of file ActionIconsTool.py.

00201                                                                     :

        """ 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.
        """
        result = {}

        for category, actions in categorized_actions.items():

            new_actions = []

            for action in actions:

                action = action.copy()

                action_id = action.get( 'id' )

                #  Hack around DCWorkflow's ID-less worklist actions.
                if action_id is None and action.get( 'category' ) == 'workflow':
                    action[ 'id' ] = action_id = action.get( 'name' )

                if action_id:

                    info = self.queryActionInfo( category
                                               , action_id
                                               , context=context
                                               )
                    if info is not None:

                        title, priority, icon = info

                        if title is not None:
                            action[ 'title' ] = title

                        if priority is not None:
                            action[ 'priority' ] = priority

                        if icon is not None:
                            action[ 'icon' ] = icon

                new_actions.append( action )

            new_actions.sort( lambda x, y: cmp( x.get( 'priority', 0 )
                                              , y.get( 'priority', 0 )
                                              ) )
            result[ category ] = new_actions

        return result

    __call__ = updateActionDicts


Generated by  Doxygen 1.6.0   Back to index