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 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 all,
I have a simple table with 3 computed fields, the function that set
their values is almost the same. However, unfortunately I had to set
up
three different functions because I didn't find a better approach.
The code:
db.define_table('cities',
Field('name', 'string', requires=IS_TRIM()),
Field('full_address', 'string',requires=IS_TRIM()),
Field("lat", "double", label=T('Latitude')),
Field("lgt", "double", label=T('Longitude')))

db.cities.full_address.compute = compute_geoCode_place
db.cities.lat.compute = compute_geoCode_lat
db.cities.lgt.compute = compute_geoCode_lng

def compute_geoCode_place(r):
g = geocoders.Google()
place, (lat, lng) = g.geocode(r.name [1])
return place

def compute_geoCode_lat(r):
g = geocoders.Google()
place, (lat, lng) = g.geocode(r.name [2])
return lat

def compute_geoCode_lng(r):
g = geocoders.Google()
place, (lat, lng) = g.geocode(r.name [3])
return lng

What I would like to find is a way to fire the execution of a
function
when the form is submitted. More or less something like a compute
action
at table level.

Regards,

--
Paolo


Links:
------
[1] http://r.name
[2] http://r.name
[3] http://r.name


Reply via email to