def get_actions_for_object_model(obj, relation_id=None):

    # -- DEPRECATED --
    # Only for backward compatibilty
    if hasattr(obj, 'get_actions'):
        # All app and plugin define a get_actions method,
        # so we check if the method is overloaded...
        get_actions = getattr(obj, 'get_actions')
        if get_actions():
            # Actions
            actions_html = []
            # Relation ID
            if not relation_id:
                relation_id = obj.get_relation_id()
            for action in get_actions():
                actions_html.append(u'<a onclick="%s(\'%s\'); return false;">%s</a>' % (
                        action[1],
                        relation_id,
                        action[0]))
            # Title
            title = obj.__class__.get_name()
            return {'title': title, 'list': actions_html}
    # -- NEW SYNTAX --
    # Only if object model defines ActionsAdmin inner class.
    if hasattr(obj, 'ActionsAdmin'):
        # Get title of actions group (or default value)
        title = getattr(obj.ActionsAdmin, 'title', _(u'Actions'))
        # Get relation_id for the first param of WA urls
        if not relation_id:
            related_obj = obj
            if not isinstance(obj, AbstractPageApp) and not isinstance(obj, AbstractPlugin):
                related_object_path = getattr(obj.ActionsAdmin, 'related_object', 'app')
                for item in related_object_path.split('__'):
                    related_obj = getattr(related_obj, item)
            relation_id = related_obj.get_relation_id()
        # Make actions list
        actions_html = []
        for action in getattr(obj.ActionsAdmin, 'actions_list', []):
            # Formating each argument (in string)
            # in order to provide the callback function
            args_formated = u''
            for arg in action.get('args', []):
                try:
                    args_formated += u', %s' % getattr(obj, arg)
                except __HOLE__:
                    pass
            actions_html.append(
                u'<a onclick="%s(\'%s\'%s); return false;">%s</a>' % (
                    action.get('callback'),
                    relation_id,
                    args_formated,
                    action.get('title'))
                )
        return {'title': title, 'list': actions_html}
    return {}
dataset/ETHPy150Open ionyse/ionyweb/ionyweb/administration/actions/utils.py/get_actions_for_object_model