Skip to content

Instantly share code, notes, and snippets.

@apetresc
Created May 16, 2012 22:16
Show Gist options
  • Select an option

  • Save apetresc/2714414 to your computer and use it in GitHub Desktop.

Select an option

Save apetresc/2714414 to your computer and use it in GitHub Desktop.
Traceback (most recent call last):
File "fb_sync.py", line 17, in <module>
dynamo.batch_write_item(new_contacts)
File "/Users/apetresc/.virtualenvs/socialSync/lib/python2.7/site-packages/boto/dynamodb/layer2.py", line 439, in batch_write_item
request_items = batch_list.to_dict()
File "/Users/apetresc/.virtualenvs/socialSync/lib/python2.7/site-packages/boto/dynamodb/batch.py", line 206, in to_dict
table_name, batch_dict = batch.to_dict()
File "/Users/apetresc/.virtualenvs/socialSync/lib/python2.7/site-packages/boto/dynamodb/batch.py", line 102, in to_dict
d = {'Item': self.table.layer2.dynamize_item(item)}
File "/Users/apetresc/.virtualenvs/socialSync/lib/python2.7/site-packages/boto/dynamodb/layer2.py", line 132, in dynamize_item
d[attr_name] = dynamize_value(item[attr_name])
TypeError: string indices must be integers, not str
for user in dynamo.scan(FacebookProfiles):
g = facegraph.Graph(user['accessToken'])
new_contacts = dynamo.new_batch_write_list()
for friend in g.me.friends().data:
print "Adding %s, %s" % (user['FacebookId'], friend.id)
new_contacts.add_batch(FacebookContacts, puts=FacebookContacts.new_item(attrs={'UserFacebookId': user['FacebookId'], 'ContactFacebookId': friend.id}))
dynamo.batch_write_item(new_contacts)
print "Done adding %d contacts to %s" % (len(new_contacts), user['FacebookId'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment