def get_approved_tools(app, sa_session):
 tools = []
 for tool in sa_session.query(app.model.Tool).order_by(app.model.Tool.table.c.name):
  if (tool.state == app.model.Tool.states.APPROVED):
   tools.append(tool)
 return tools

def get_approved_tools ( app , sa_session ) : tools = [ ] for tool in sa_session . query ( app . model . Tool ) . order_by ( app . model . Tool . table . c . name ) : if ( tool . state == app . model . Tool . states . APPROVED ) : tools . append ( tool ) return tools
get only the latest version of each tool from the database whose state is approved .