Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 为什么我会得到;实例没有属性“u caller”;使用web2py向外部API发出post请求时出错_Python_Http Post_Urllib2_Web2py - Fatal编程技术网

Python 为什么我会得到;实例没有属性“u caller”;使用web2py向外部API发出post请求时出错

Python 为什么我会得到;实例没有属性“u caller”;使用web2py向外部API发出post请求时出错,python,http-post,urllib2,web2py,Python,Http Post,Urllib2,Web2py,我试图从自己的API获取数据以填充我的web2py数据库。当我从我的操作系统默认python解释器(2.7)发出post请求时,这可以正常工作,但当我在web2py环境中运行完全相同的代码时,我得到以下错误: AttributeError: addinfourl instance has no attribute '_caller' Web2Py也运行在相同的python版本上。以下是我在web2py project//models/x_fixtures中的测试代码: import json

我试图从自己的API获取数据以填充我的web2py数据库。当我从我的操作系统默认python解释器(2.7)发出post请求时,这可以正常工作,但当我在web2py环境中运行完全相同的代码时,我得到以下错误:

AttributeError: addinfourl instance has no attribute '_caller'
Web2Py也运行在相同的python版本上。以下是我在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)
编辑: 错误的完整回溯:

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'

response
是web2py使用的一个全局变量;您的代码只是在上面踩了一下,这会破坏控制器。

错误中引用的实例没有出现在发布的代码中,您也没有指出它引用的代码。我已经编辑了我的答案并添加了其他详细信息:)我仍然看不到
addInfo URL
任何地方;
x_fixtures
似乎也没有14行。如果我将您的模型文件放到web2py实例中(将DB调用替换为True),它将发出请求(由于存在虚假URL,请求失败)。感谢您尝试,将URL编辑为真实URL。如果您使用正确的URL进行测试,您可能会看到错误与项目无关
# -*- 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()