def survey_getQuestionFromName(name, series_id):
 s3db = current.s3db
 sertable = s3db.survey_series
 q_ltable = s3db.survey_question_list
 qsntable = s3db.survey_question
 query = ((((sertable.id == series_id) & (q_ltable.template_id == sertable.template_id)) & (q_ltable.question_id == qsntable.id)) & (qsntable.name == name))
 record = current.db(query).select(qsntable.id, qsntable.code, qsntable.name, qsntable.type, q_ltable.posn, limitby=(0, 1)).first()
 if (record is None):
  loc_list = current.gis.get_all_current_levels()
  for row in loc_list.items():
   if (row[1] == name):
    return survey_getQuestionFromName(row[0], series_id)
 question = {}
 question_row = record.survey_question
 question['qstn_id'] = question_row.id
 question['code'] = question_row.code
 question['name'] = question_row.name
 question['type'] = question_row.type
 question['posn'] = record.survey_question_list.posn
 return question

def survey_getQuestionFromName ( name , series_id ) : s3db = current . s3db sertable = s3db . survey_series q_ltable = s3db . survey_question_list qsntable = s3db . survey_question query = ( ( ( ( sertable . id == series_id ) & ( q_ltable . template_id == sertable . template_id ) ) & ( q_ltable . question_id == qsntable . id ) ) & ( qsntable . name == name ) ) record = current . db ( query ) . select ( qsntable . id , qsntable . code , qsntable . name , qsntable . type , q_ltable . posn , limitby = ( 0 , 1 ) ) . first ( ) if ( record is None ) : loc_list = current . gis . get_all_current_levels ( ) for row in loc_list . items ( ) : if ( row [ 1 ] == name ) : return survey_getQuestionFromName ( row [ 0 ] , series_id ) question = { } question_row = record . survey_question question [ 'qstn_id' ] = question_row . id question [ 'code' ] = question_row . code question [ 'name' ] = question_row . name question [ 'type' ] = question_row . type question [ 'posn' ] = record . survey_question_list . posn return question
function to return the question for the given series with the name that matches the one passed in .