just share, hope can help others *e.g.* *controllers/default.py* def test(): table = db.test
if session.lat and session.lon: table.lat.default = session.lat table.lon.default = session.lon #import gluon.contrib.simplejson #import urllib #import json import requests url = 'http://maps.googleapis.com/maps/api/geocode/json?latlng=%s,%s&sensor=true' % (session.lat, session.lon) #jsonurl = urllib.urlopen(url) #urllib.urlopen #data = gluon.contrib.simplejson.loads(jsonurl.read() ) #data = json.loads(jsonurl.read() ) jsonurl = requests.get(url) # requests data = jsonurl.json() table.address.default = data['results'][0]['formatted_address'] table.zip_code.default = data['results'][0]['address_components'][10]['long_name'] table.city.default = data['results'][0]['address_components'][8]['long_name'] table.country.default = data['results'][0]['address_components'][9]['long_name'] fields = None form = SQLFORM(table, fields = fields) if form.process(formname = 'form_modal').accepted: current.response.flash = 'form has submitted' elif form.errors: current.response.flash = 'form has errors' return dict(form = form) best regards, stifan -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.

