given

  db.define_table('person',Field('name'))
  id = db.person.insert(name='john')

You can now do

  print db.person(id)
  print db.person(db.person.name=='john')
  print db.person(name='john')
  print db.person(id,name='john')

they all return the same record 'john'. On failure (record does not
exist) they return None. This allows the following syntax:

  record = db.person(request.args(0)) or redirect(URL('error'))

this is better than

  record = db.person[request.args(0)] or redirect(URL('error'))

since the latter raises an exception in case request.args(0) is not
None or an int.



Reply via email to