'This method store an action object in the session and returns an integer
identifying that action. The method get_action() can be used to get
back the action.
:param the_action: The action to save in the session.
:type the_action: anything
:return: A key identifying the saved action.
:rtype: integer'

def save_action(self, action):

    saved_actions = self.setdefault('saved_actions', {'next': 1, 'actions': {}})
    if (len(saved_actions['actions']) >= 10):
        del saved_actions['actions'][min(saved_actions['actions'])]
    key = saved_actions['next']
    saved_actions['actions'][key] = action
    saved_actions['next'] = (key + 1)
    self.modified = True
    return key
