尝试向 couchdb 发出请求时,HttpLib2 抛出错误
我正在Python2.6 中构建一个需要从CouchDb 获取数据的应用程序。我使用 CouchDB-0.8-py2.6 连接到数据库。 我正在使用这段代码:
import couchdb
server = couchdb.Server(url='http://localhost:5984/', full_commit=True, session=None)
db = server['databaseName']
doc = db['docId']
value = doc['value']
print(value)
在我的本地计算机(OSX)上,代码运行完美,但是当我尝试在 Debian 服务器上运行它时,我收到以下错误:
File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.7dev_r199-py2.6.egg/couchdb/client.py", line 165, in __getitem__
db.resource.head() # actually make a request to the database
File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.7dev_r199-py2.6.egg/couchdb/client.py", line 977, in head
return self._request('HEAD', path, headers=headers, **params)
File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.7dev_r199-py2.6.egg/couchdb/client.py", line 1010, in _request
resp, data = _make_request()
File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.7dev_r199-py2.6.egg/couchdb/client.py", line 1005, in _make_request
body=body, headers=headers)
File "/usr/local/lib/python2.6/dist-packages/httplib2-0.6.0-py2.6.egg/httplib2/__init__.py", line 1025, in request
cached_value = self.cache.get(cachekey)
AttributeError: 'bool' object has no attribute 'get'
我尝试用 Google 搜索多次,但没有-一个似乎有同样的错误。有谁知道我在这里做错了什么?
I'm building an application in Python2.6 that needs to get data from CouchDb. I'm using CouchDB-0.8-py2.6 to connect to the database.
I'm using this code:
import couchdb
server = couchdb.Server(url='http://localhost:5984/', full_commit=True, session=None)
db = server['databaseName']
doc = db['docId']
value = doc['value']
print(value)
On my local machine (OSX) the code runs perfectly, but when I'm trying to run it on a Debian server, I get the following error:
File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.7dev_r199-py2.6.egg/couchdb/client.py", line 165, in __getitem__
db.resource.head() # actually make a request to the database
File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.7dev_r199-py2.6.egg/couchdb/client.py", line 977, in head
return self._request('HEAD', path, headers=headers, **params)
File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.7dev_r199-py2.6.egg/couchdb/client.py", line 1010, in _request
resp, data = _make_request()
File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.7dev_r199-py2.6.egg/couchdb/client.py", line 1005, in _make_request
body=body, headers=headers)
File "/usr/local/lib/python2.6/dist-packages/httplib2-0.6.0-py2.6.egg/httplib2/__init__.py", line 1025, in request
cached_value = self.cache.get(cachekey)
AttributeError: 'bool' object has no attribute 'get'
I've tried to Google this numerous times and no-one seems to have the same error. Does anyone have an idea what I'm doing wrong here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在服务器上使用不同版本的 CouchDB - CouchDB-0.7dev_r199。 CouchDB 不再使用 httplib2,因此如果您的开发环境和服务器环境大致相同,那么问题很可能会消失。
You're using a different version of CouchDB on the server - CouchDB-0.7dev_r199. CouchDB does not use httplib2 anymore, so if you get your development and server environments roughly the same the problem is quite likely to disappear.