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?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to