#NEWLINE# @ classmethod #NEWLINE# def _query_order_by( cls , query , order_by ) : #NEWLINE# #INDENT# "Adds order by clause into SQLAlchemy query\n\n        :param query: SQLAlchemy query\n        :param order_by: tuple of model fields names for ORDER BY criterion\n        to SQLAlchemy query. If name starts with '-' desc ordering applies,\n        else asc.\n        " #NEWLINE# order_args = [ ] #NEWLINE# for field_name in order_by : #NEWLINE# #INDENT# if field_name . startswith ( '-' ) : #NEWLINE# #INDENT# field_name = field_name . lstrip ( '-' ) #NEWLINE# ordering = 'desc' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ordering = 'asc' #NEWLINE# #UNINDENT# field = getattr ( cls . single . model , field_name ) #NEWLINE# o_func = getattr ( o_func , ordering ) #NEWLINE# order_args . append ( o_func ( ) ) #NEWLINE# #UNINDENT# query = query . order_by ( * order_args ) #NEWLINE# return query