def get_connected_roles(action_id):
try:<EOL><INDENT>from invenio.access_control_admin import compile_role_definition<EOL><DEDENT>except ImportError:<EOL><INDENT>from invenio.modules.access.firerole import compile_role_definition<EOL><DEDENT>run_sql = _get_run_sql()<EOL>roles = {}<EOL>res = run_sql(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>', (action_id, )<EOL>)<EOL>for r in res:<EOL><INDENT>role = roles.setdefault(<EOL>r[<NUM_LIT:0>], {<EOL>'<STR_LIT:id>': r[<NUM_LIT:0>],<EOL>'<STR_LIT:name>': r[<NUM_LIT:1>],<EOL>'<STR_LIT:description>': r[<NUM_LIT:2>],<EOL>'<STR_LIT>': r[<NUM_LIT:3>],<EOL>'<STR_LIT>': compile_role_definition(r[<NUM_LIT:3>]),<EOL>'<STR_LIT>': set(),<EOL>'<STR_LIT>': {}<EOL>}<EOL>)<EOL>param = role['<STR_LIT>'].setdefault(r[<NUM_LIT:4>], set())<EOL>param.add(r[<NUM_LIT:5>])<EOL>role['<STR_LIT>'].add(r[<NUM_LIT:6>])<EOL><DEDENT>return six.itervalues(roles)<EOL>
Get roles connected to an action.