#NEWLINE# def _set_rules_for_policy_rule_set( self , context , policy_rule_set_db , rule_id_list ) : #NEWLINE# #INDENT# prs_db = policy_rule_set_db #NEWLINE# if ( not rule_id_list ) : #NEWLINE# #INDENT# prs_db . policy_rules = [ ] #NEWLINE# return #NEWLINE# #UNINDENT# with context . session . begin ( subtransactions = True ) : #NEWLINE# #INDENT# filters = { #NEWLINE# #INDENT# 'id' : [ r_id for r_id in rule_id_list ] , #NEWLINE# #UNINDENT# } #NEWLINE# rules_in_db = self . _get_collection_query ( context , PolicyRule , filters = filters ) #NEWLINE# rule_ids = set ( ( r_db [ 'id' ] for r_db in rules_in_db ) ) #NEWLINE# for rule_id in rule_id_list : #NEWLINE# #INDENT# if ( rule_id not in rule_ids ) : #NEWLINE# #INDENT# raise gpolicy . PolicyRuleNotFound ( policy_rule_id = rule_id ) #NEWLINE# #UNINDENT# #UNINDENT# prs_db . policy_rules = [ ] #NEWLINE# for rule_id in rule_id_list : #NEWLINE# #INDENT# prs_rule_db = PRSToPRAssociation ( policy_rule_id = rule_id , policy_rule_set_id = prs_db . id ) #NEWLINE# prs_db . policy_rules . append ( context )