def get_loc_from_db(location, country):
 row = db((table.name == location)).select(table.level, table.L1, table.L2, table.L3, orderby=table.level, limitby=(0, 1)).first()
 if (row is None):
  return lookup_loc(location, country)
 country_code = country_codes[country]
 return (country_code, row.L1, row.L2, row.L3)

def get_loc_from_db ( location , country ) : row = db ( ( table . name == location ) ) . select ( table . level , table . L1 , table . L2 , table . L3 , orderby = table . level , limitby = ( 0 , 1 ) ) . first ( ) if ( row is None ) : return lookup_loc ( location , country ) country_code = country_codes [ country ] return ( country_code , row . L1 , row . L2 , row . L3 )
lookup a location hierarchy .