lanto03 / couchdb-python

Automatically exported from code.google.com/p/couchdb-python
Other
0 stars 0 forks source link

Calling len() on a ViewResult raises an Exception #30

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I call a named view and then check the number of results by calling len().

I receive the following traceback:

  if len(result) == 0:
  File "build/bdist.linux-i686/egg/couchdb/client.py", line 722, in __len__
    return len(self.rows)
  File "build/bdist.linux-i686/egg/couchdb/client.py", line 733, in _get_rows
    self._fetch()
  File "build/bdist.linux-i686/egg/couchdb/client.py", line 727, in _fetch
    for r in data['rows']]
TypeError: string indices must be integers

Original issue reported on code.google.com by xocli...@gmail.com on 3 Nov 2008 at 6:09

GoogleCodeExporter commented 8 years ago
Looks like the CouchDB server is returning some JSON structure that we don't 
expect here. It would help 
tremendously if you could log away `repr(data)` when you get this error.

Original comment by cmlenz on 5 Nov 2008 at 5:03

GoogleCodeExporter commented 8 years ago
\rTransfer-Encoding: chunked\r\nServer: CouchDB/0.8.1-incubating (Erlang 
OTP/R12B)\r\nDate: Wed, 05 Nov 
2008 22:15:49 GMT\r\nContent-Type: application/json\r\nCache-Control: must-
revalidate\r\n\r\n1e0\r\n{"total_rows":185,"offset":28,"rows":[\r\n{"id":"8dadd2
985b5abad4868aa87c0458443c
","key":"abcde","value":{"_id":"8dadd2985b5abad4868aa87c0458443c","_rev":"129703
8619","last_contact":"2008
-11-05T22:14:16Z","userid":"4b8ef20c01101c587171f232ef73ed3d","device_id":555555
5,"date_added":"2008-
10-31T13:28:17Z","secret_key":"fffffff","type":"device","name":"adfsafd"}}\r\n4\
r\n\r\n]}\r\n0\r\n\r\n

Original comment by xocli...@gmail.com on 5 Nov 2008 at 10:48

GoogleCodeExporter commented 8 years ago
Via IRC: seems to have been an issue with using a Server instance across 
multiple threads. httplib or httplib2 is 
apparently not thread-safe.

Original comment by cmlenz on 26 Nov 2008 at 8:47