I want to select teachers that have taught for more than one year, are 
getting paid and have a friendly sounding first name. 
The friendly sounding names are stored in a table, along with their 
expected position in the name.

Currently I'm using this:

teacher_query = db.teachers.years_taught!=0
teacher_query &= db.teachers.status=='Paid'

whitelisting = db.teachers.first_name=='zzzzzzzzzzz'

friendly = 
db(db.friendly_names).select(db.friendly_names.name,db.friendly_names.position)
for x in friendly:
    if x['position'] == 'Leading':
        whitelisting |= db.teachers.first_name.startswith(x['name'])
    else:
        whitelisting |= db.teachers.first_name.contains(x['name'])

teacher_query &= whitelisting

Is there a better way to get the whitelist sub-query started?
Should I do a counter inside the for loop and initialize 'whitelisting' if 
it's the first friendly name, or is there a method I'm missing from W2P?


-- 



Reply via email to