def _get_unique_table_field_values(model, field, sort_field):
 if ((field not in model.all_keys()) or (sort_field not in model.all_keys())):
  raise KeyError
 with g.lib.transaction() as tx:
  rows = tx.query('SELECT DISTINCT "{0}" FROM "{1}" ORDER BY "{2}"'.format(field, model._table, sort_field))
 return [row[0] for row in rows]

def _get_unique_table_field_values ( model , field , sort_field ) : if ( ( field not in model . all_keys ( ) ) or ( sort_field not in model . all_keys ( ) ) ) : raise KeyError with g . lib . transaction ( ) as tx : rows = tx . query ( 'SELECT DISTINCT "{0}" FROM "{1}" ORDER BY "{2}"' . format ( field , model . _table , sort_field ) ) return [ row [ 0 ] for row in rows ]
retrieve all unique values belonging to a key from a model .