numahell/collective.addthis — comment on commit 28808a3546ae593fc880d9612b9ce7cb5815758c
File: collective/addthis/social_media.py line 20
By jean:

> Oh sorry, I wanted to write :
>
> if len(response.readlines()) == 0:

That would be correct, yes.

> But now I think a better way to do is to test the http response code :

Definitely better. Reading the entire response and ignoring it is
needlessly expensive.

Could it happen that an empty response is successfully returned? (I.e.
`code='200'` and `len(response.readlines())==0`?)

If so, perhaps:

if response.code == "200":
data = json.load(response)
if data:
return data[u'data']
return []

--
jean . .. .... //\\\oo///\\