Comments (6)
Also the same problem on the master branch communicating with mobile REST api:
$ hg clone https://code.google.com/p/couchdb-python/
$ cd couchdb-python/
$ python
Python 2.7.5+ (default, Feb 27 2014, 19:37:08)
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path = ["."] + sys.path
>>> from couchdb import Server
>>> s = Server("http://admin:super_secret_password@localhost:5984")
>>> db = s["mica"]
>>> db["foo"] = {"bar" : "hello"}
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "./couchdb/client.py", line 350, in __setitem__
status, headers, data = resource.put_json(body=content)
File "./couchdb/http.py", line 541, in put_json
**params)
File "./couchdb/http.py", line 557, in _request_json
if 'application/json' in headers.get('content-type'):
TypeError: argument of type 'NoneType' is not iterable
>>>
Any ideas?
Original comment by [email protected]
on 5 Jun 2014 at 3:43
from couchdb-python.
Also, here's the *working HTTP response from my real couchdb server:
Server: CouchDB/1.4.0 (Erlang OTP/R16B01)
Location: http://localhost:5984/mica/foo2
ETag: "1-0b26fd22294459c090b330f5cae3e3b3"
Date: Thu, 05 Jun 2014 04:29:25 GMT
Content-Type: application/json
Content-Length: 67
Cache-Control: must-revalidate
Original comment by [email protected]
on 5 Jun 2014 at 4:30
from couchdb-python.
Ah, that's a stupid bug. I pushed this oneliner to the default branch
(rfe57285ec470):
diff --git a/couchdb/http.py b/couchdb/http.py
--- a/couchdb/http.py
+++ b/couchdb/http.py
@@ -554,7 +554,7 @@
def _request_json(self, method, path=None, body=None, headers=None, **params):
status, headers, data = self._request(method, path, body=body,
headers=headers, **params)
- if 'application/json' in headers.get('content-type'):
+ if 'application/json' in headers.get('content-type', ''):
data = json.decode(data.read().decode('utf-8'))
return status, headers, data
This will be in the next release, although that is still waiting for some
further resolution of #231. Also, I would argue that couchbase-mobile is wrong
for not providing the header in the first place.
Original comment by djc.ochtman
on 5 Jun 2014 at 7:18
- Changed state: Fixed
from couchdb-python.
Ummm, not quite fixed =). Here's the new result after doing 'hg update':
$ python
>>> db["foo"] = { "bar" : 1 }
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "./couchdb/client.py", line 350, in __setitem__
status, headers, data = resource.put_json(body=content)
File "./couchdb/http.py", line 541, in put_json
**params)
File "./couchdb/http.py", line 556, in _request_json
headers=headers, **params)
File "./couchdb/http.py", line 552, in _request
credentials=self.credentials)
File "./couchdb/http.py", line 392, in request
data = json.decode(data.decode('utf-8'))
AttributeError: 'ResponseBody' object has no attribute 'decode'
Original comment by [email protected]
on 5 Jun 2014 at 8:01
from couchdb-python.
That's probably a different bug, likely a regression due to the Python 3
porting effort in the default branch. However, that exception is a little
weird, as it implies that you're trying to process an error response that is
quite large (larger than 8k). It's also not covered by the test suite,
apparently. Could you please open a new bug about it? It would be awesome if
you could write a test case (see couchdb/tests) or other script that triggers
this (ideally against a normal CouchDB server).
Original comment by djc.ochtman
on 5 Jun 2014 at 8:16
from couchdb-python.
Darn. I don't work for couchbase - so I'm not sure how I would write such a
test case =(. But, I'll post on the couchbase community and see if they can
help out.
Original comment by [email protected]
on 6 Jun 2014 at 4:23
from couchdb-python.
Related Issues (20)
- How to check for _active_tasks HOT 2
- Pypi release HOT 3
- couchdb-dump attribute error: 'Resource' object has no attribute 'http' HOT 1
- Database.view() and list() don't work on Google's AppEngine HOT 3
- Consecutives POST requests concatenates request bodies on App Engine HOT 1
- Provide ability to do bulk dump and load HOT 7
- NonASCII data in map/reduce functions when using stdlib json HOT 1
- Can't access update_seq attribute from view result HOT 1
- Enhancement: support for defining and syncing of 'validate_doc_update', 'updates' and 'shows' entities in design document HOT 9
- Document Update Handler (update_doc) support for PUT and POST HOT 8
- python 3 support HOT 21
- Non-ascii content doesn't work HOT 4
- CouchDB errors are not reported cleanly (shows up as exception from simplejson) HOT 2
- Add view server support for ddoc functions HOT 2
- Doc write exception with unicode characters HOT 5
- Python 3 install failure HOT 4
- _security object is an exception to the document model HOT 5
- Fail on generation basic auth header for python 3 HOT 3
- tools/replicate isn't compatible with python 3 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from couchdb-python.