histrio / py-couchdb

Modern pure python CouchDB Client.
https://pycouchdb.readthedocs.org/
Other
120 stars 43 forks source link

json.encode(value), AttributeError: 'module' object has no attribute 'encode' #7

Closed KodjoSuprem closed 11 years ago

KodjoSuprem commented 11 years ago

I want to get all design docs from a db:

for doc in db.all(startkey="_design/", endkey="_design0"):

and gets

File "...\pycouchdb\utils.py", line 116, in _encode_view_options
    value = json.encode(value)
AttributeError: 'module' object has no attribute 'encode'

I naively fixed it with the utils.to_json() function

flexd commented 11 years ago

I fixed this in #8, I didn't even know this issue existed but using json.JSONEncoder() is better (and the intended way) :-) json itself has no encode()

niwinz commented 11 years ago

Now fixed in https://github.com/niwibe/py-couchdb/commit/cb665f3205ac848eed219a15e2ffc663a0c2bc45 Thanks for report!