#NEWLINE# @ classmethod #NEWLINE# def lock_for_update( cls , iterable ) : #NEWLINE# #INDENT# 'Use SELECT FOR UPDATE on a given iterable (query).\n\n        In case if iterable=None returns all object instances\n\n        :param iterable: iterable (SQLAlchemy query)\n        :returns: filtered iterable (SQLAlchemy query)\n        ' #NEWLINE# use_iterable = ( iterable or cls . all ( ) ) #NEWLINE# if cls . _is_query ( use_iterable ) : #NEWLINE# #INDENT# return use_iterable . with_lockmode ( 'update' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if cls . _is_iterable ( use_iterable ) : #NEWLINE# #INDENT# return use_iterable #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise TypeError ( 'First argument should be iterable' )