#NEWLINE# @ classmethod #NEWLINE# def filter_by_list( cls , iterable , field_name , list_of_values , order_by = ( ) ) : #NEWLINE# #INDENT# 'Filter given iterable by list of list_of_values.\n\n        In case if iterable=None filters all object instances\n\n        :param iterable: iterable (SQLAlchemy query)\n        :param field_name: filtering field name\n        :param list_of_values: list of values for objects filtration\n        :returns: filtered iterable (SQLAlchemy query)\n        ' #NEWLINE# field_getter = operator . attrgetter ( field_name ) #NEWLINE# use_iterable = ( iterable or cls . all ( ) ) #NEWLINE# if cls . _is_query ( use_iterable ) : #NEWLINE# #INDENT# result = use_iterable . filter ( field_getter ( cls . single . model ) . in_ ( list_of_values ) ) #NEWLINE# result = cls . order_by ( result , order_by ) #NEWLINE# return result #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if cls . _is_iterable ( use_iterable ) : #NEWLINE# #INDENT# return ifilter ( ( lambda i : ( field_getter ( i ) in list_of_values ) ) , order_by ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise TypeError ( 'First argument should be iterable' )