I have a model with latitude and longitude fields. The lat and lng should be computed from the address via Google geocoding. Whenever the model is inserted or updated I want to update the lat and lng from the address of the model.
In Yii PHP framework there a number of events that you can customize surrounding models. One of them is the beforeSave event (see
http://www.yiiframework.com/doc/api/1.1/CActiveRecord#beforeSave-detail) which is called every time before a model is saved to the database and which I could use to call a geocode function and stuff the resulting lat and lng into fields before saving to the database. This works no matter where you are saving the model from.
How can I get similar behavior in web2py?
Currently I have a controller where in the "create()" function I use onvalidation parameter of the form.process method to trigger the geocoding. This works but then I would need to repeat this logic in an "update()" controller function. And how would I get this to work when creating or updating records from the appadmin interface?