that's because db.person1.visits in an expressions is turned to the string 'person1.visits' and all databases understand
update person1 set person1.visits = person1.visits + 1 when you do db.person1.name.capitalize(), you are willing to have a database that executes a python function (capitalize()): that is not supported by databases, so web2py doesn't let you do that. if you want to exploit the "potentials" of python functions, you need to update one record at a time passing the "pre-calculated" value to the database. On Saturday, November 10, 2012 7:02:42 PM UTC+1, mweissen wrote: > > I have tried this example > > def visit(): > db(db.person1.id>0).update( > visits = db.person1.visits + 1, > ) > > It is in the book and works fine. > Now I have added another line... > > def visit(): > db(db.person1.id>0).update( > visits = db.person1.visits + 1, > name = db.person1.name.capitalize(), > ) > > .. and I got an error: > <type 'exceptions.AttributeError'> 'Field' object has no attribute > 'capitalize'(1) I do not understand why it is possible to add 1 to a > field, but not to do something other with a string. > > (2) Is there any simple solution? Of course I could write something like > > for r in db(db.person1.id>0).select(): > ... update ... > > Regards, Martin > > --