I'm trying to fetch data to populate my web2py database from my own API. This works fine when I make the post request from my operating systems default python Interpreter (2.7) but when I run the exact same code in web2py-enviroment I get this error:
AttributeError: addinfourl instance has no attribute '_caller'
Web2Py also runs on same python version. Here's my test-code located in web2py project//models/x_fixtures:
import json
import urllib2
if db(db.rftable.id > 0).count() == 0:
data = {
'ids': [12, 3, 4, 5, 6]
}
url = 'https://eo7sjt6hvj.execute-api.us-west-2.amazonaws.com/prod/tables/getall'
req = urllib2.Request(url, json.dumps(data), {'Content-Type': 'application/json'})
response = urllib2.urlopen(req)
EDIT: Entire Traceback of the error:
Traceback (most recent call last):
File "/home/toni/repos/python/web2py/fsttrpg/gluon/restricted.py", line 219, in restricted
exec(ccode, environment)
File "/home/toni/repos/python/web2py/fsttrpg/applications/fsttrpg/controllers/default.py", line 14, in <module>
AttributeError: addinfourl instance has no attribute '_caller'
My default/controller:
# -*- coding: utf-8 -*-
### required - do no delete
def user(): return dict(form=auth())
def download(): return response.download(request,db)
def call(): return service()
### end requires
def index():
return dict()
def error():
return dict()
response
is one of the globals that web2py uses; your code just stomped on it, which breaks the controller.