[web2py] Re: Multi computed fields

2012-05-17 Thread Niphlod
The onsuccess parameter of form.process() seems to cover your problems: from http://web2py.com/books/default/chapter/29/7 onsuccess and onfailure can be functions like lambda form: do_something(form) Il giorno giovedì 17 maggio 2012 10:35:46 UTC+2, Gabriella Canavesi ha scritto: Hi

[web2py] Re: Multi computed fields

2012-05-17 Thread Anthony
To get it down to it down to one function, how about: def compute_geoCode(r, component): g = geocoders.Google() place, (lat, lng) = g.geocode(r.name) return eval(component) db.cities.full_address.compute = lambda r: compute_geoCode(r, 'place') db.cities.lat.compute = lambda r:

Re: [web2py] Re: Multi computed fields

2012-05-17 Thread Paolo
Hi Niphlod, thanks for your answer. Actually, I am looking for something that I can put in my model without touch the code of the forms, e.g., I don't want to change the code of the admin application to solve the problem. Paolo Il 17.05.2012 13:14 Niphlod ha scritto: The onsuccess parameter

Re: [web2py] Re: Multi computed fields

2012-05-17 Thread Paolo
Hi Anthony, thanks for the answer, Your solution is pretty nice but I am still calling it 3 times which actually is the main problem since I am asking 'google' 3 times the same stuff. Is it possible to store the answer somewhere (cache?) the first time and then use the cache copy for the

Re: [web2py] Re: Multi computed fields

2012-05-17 Thread Anthony
def compute_geoCode(r, component): g = geocoders.Google() place, (lat, lng) = cache.ram(r.name, lambda: g.geocode(r.name), None) return eval(component) Anthony On Thursday, May 17, 2012 11:44:16 AM UTC-4, Gabriella Canavesi wrote: Hi Anthony, thanks for the answer, Your

Re: [web2py] Re: Multi computed fields

2012-05-17 Thread Anthony
Hi Niphlod, thanks for your answer. Actually, I am looking for something that I can put in my model without touch the code of the forms, e.g., I don't want to change the code of the admin application to solve the problem. In this case, I think caching in the compute_geoCode function is

Re: [web2py] Re: Multi computed fields

2012-05-17 Thread Paolo
This is perfect! Thank you very much Anthony. Paolo Il 17.05.2012 16:47 Anthony ha scritto: def compute_geoCode(r, component): g = geocoders.Google() place, (lat, lng) = cache.ram(r.name, lambda: g.geocode(r.name [9]), None) return eval(component) Anthony On Thursday, May 17, 2012