#NEWLINE# def filter_object_id_list( object_list , user_id , permission_id ) : #NEWLINE# #INDENT# query = '\n        SELECT ctype_id, object_id FROM ({ids_query}) AS ids\n        WHERE EXISTS (SELECT op.id FROM {permission_owners} WHERE {filter_condition})\n    ' #NEWLINE# query = query . format ( ids_query = generate_obj_list_query ( object_list ) , permission_owners = get_permission_owners_query ( ) , filter_condition = _generate_filter_condition ( user_id , permission_id , 'ids.ctype_id' , 'ids.object_id' ) ) #NEWLINE# cursor = connection . cursor ( ) #NEWLINE# cursor . execute ( query ) #NEWLINE# return [ ( row [ 0 ] , query [ 1 ] ) for row in cursor . fetchall ( ) ]