urschrei/pyzotero — Issue #13: Basic "hello world" code broken
Author: rdhyee
Created: 2012-01-13 15:59:39+00:00
State: open

I ran the following code (taken from http://pyzotero.readthedocs.org/en/latest/index.html#hello-world):

from zoteroconf import user_id, user_key

# http://pyzotero.readthedocs.org/en/latest/index.html

from pyzotero import zotero
zot = zotero.Zotero(user_id, user_key)
items = zot.items()
for item in items:
print 'Author: %s | Title: %s' % (item['creators'][0]['lastName'], item['title'])

with pyzotero 0.9.3 and got the following error:

Traceback (most recent call last):
File "pyzotero_test.py", line 9, in
print 'Author: %s | Title: %s' % (item['creators'][0]['lastName'], item['title'])
TypeError: string indices must be integers

Traceback (most recent call last):
File "pyzotero_test.py", line 7, in
items = zot.items()
File "/home/ubuntu/.virtualenvs/zoterotest/lib/python2.7/site-packages/pyzotero/zotero.py", line 102, in wrapped_f
return self._process_content(parsed)
File "/home/ubuntu/.virtualenvs/zoterotest/lib/python2.7/site-packages/pyzotero/zotero.py", line 552, in _process_content
return self._standard_items(content)
File "/home/ubuntu/.virtualenvs/zoterotest/lib/python2.7/site-packages/pyzotero/zotero.py", line 569, in _standard_items
for e in retrieved.entries]
File "/usr/lib/python2.7/json/__init__.py", line 326, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 360, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 378, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

When I run the code with a version of pyzotero that worked for me in November 2011 (0.9.1), I get the following error:

Traceback (most recent call last):
File "pyzotero_test.py", line 9, in
print 'Author: %s | Title: %s' % (item['creators'][0]['lastName'], item['title'])
TypeError: string indices must be integers

I'm using Python 2.7.1+ on ubuntu. I get the same errors running Python 2.7 on OS X.