views:

23

answers:

1

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?

+1  A: 

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.

Matt Goodall
Thanks for your answer! I'll have to look into that. We had a lot of problems installing the python-couchdb lib on the server. We eventually checked it out from the repo, but that one appears to be an old version...
Willem Oostendorp
It worked installing the newest version. Thanks alot!
Willem Oostendorp