Giter Site home page Giter Site logo

Comments (6)

GoogleCodeExporter avatar GoogleCodeExporter commented on August 11, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 11, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 11, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 11, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 11, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 11, 2024
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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.