Back to index

plone3  3.1.7
getOrderedUserActions.py
Go to the documentation of this file.
00001 ## Script (Python) "getOrderedUserActions"
00002 ##bind container=container
00003 ##bind context=context
00004 ##bind namespace=
00005 ##bind script=script
00006 ##bind subpath=traverse_subpath
00007 ##parameters=keyed_actions=None, ordering=None
00008 ##title=Depending on the context return the actions for a personalbar
00009 ##
00010 
00011 context.plone_log("The getOrderedUserActions script is deprecated and will be "
00012                   "removed in Plone 4.0.")
00013 
00014 if keyed_actions is None:
00015     keyed_actions=context.keyFilteredActions()
00016 
00017 if ordering is None:
00018     preordering=['mystuff', 'preferences', 'undo']
00019     postordering=['configPortal', 'logout']
00020 else:
00021     preordering=ordering['pre']
00022     postordering=ordering['post']
00023 
00024 totalordering=preordering+postordering
00025 
00026 ordered_actions=[]
00027 user_actions=keyed_actions['user']
00028 
00029 for id in preordering:
00030     if user_actions.get(id, None) is not None:
00031         ordered_actions.append( user_actions[id].copy() )
00032 
00033 ordered_actions+=[ action.copy() for action in user_actions.values()
00034                    if action['id'] not in totalordering ]
00035 
00036 for id in postordering:
00037     if user_actions.get(id, None) is not None:
00038         ordered_actions.append( user_actions[id].copy() )
00039 
00040 return ordered_actions