Alex I think you're slightly confused, let me explain. This was the original controller function I suggested.
def locateme(): import json from gluon.tools import fetch location_data = json.loads(fetch('http://ipinfo.io/%s/json' % request. client)) return location_data Note that it returns location_data, what is location data? Well it's a dict because that's what the API returns and the json module takes care of that for us. In web2py, controller functions that return dicts make the keys in that dictionary available in the view. So in the view you shouldn't be acessing location_data directly you should be accessing its keys. To further illustrate I could rewrite locateme like this def locateme(): import json from gluon.tools import fetch location_data = json.loads(fetch('http://ipinfo.io/%s/json' % request. client)) return dict(city=location_data[u'city'], region=location_data[u'region'], country=location_data[u'country'],) But this would be superfluous because location_data is already a dict I can perfectly well return. -- 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/d/optout.