#NEWLINE# @ classmethod #NEWLINE# def get_by_uid( cls , uid , fail_if_not_found = False , lock_for_update = False ) : #NEWLINE# #INDENT# "Get instance by it's uid (PK in case of SQLAlchemy)\n\n        :param uid: uid of object\n        :param fail_if_not_found: raise an exception if object is not found\n        :param lock_for_update: lock returned object for update (DB mutex)\n        :returns: instance of an object (model)\n        " #NEWLINE# q = db ( ) . query ( cls . model ) #NEWLINE# if lock_for_update : #NEWLINE# #INDENT# q = q . with_lockmode ( 'update' ) #NEWLINE# #UNINDENT# res = q . get ( uid ) #NEWLINE# if ( ( not res ) and fail_if_not_found ) : #NEWLINE# #INDENT# raise errors . ObjectNotFound ( "Object '{0}' with UID={1} is not found in DB" . format ( cls . __name__ , uid ) ) #NEWLINE# #UNINDENT# return res