Comment 6 for bug 398119

Revision history for this message
Edward Betts (edwardbetts) wrote :

Happened again:

Traceback (most recent call last):
  File "find_import_works.py", line 52, in <module>
    to_update = update_works(akey, works, do_updates=True)
  File "/1/edward/src/openlibrary/openlibrary/catalog/works/find_works.py", line 644, in update_works
    updated = new_work(akey, w, do_updates, fh_log)
  File "/1/edward/src/openlibrary/openlibrary/catalog/works/find_works.py", line 472, in new_work
    print >> fh_log, ol.save_many(update, "add editions to new work")
  File "/1/edward/src/openlibrary/openlibrary/api.py", line 125, in save_many
    return self._call_write('save_many', query, comment, action)
  File "/1/edward/src/openlibrary/openlibrary/api.py", line 121, in _call_write
    response = self._request('/api/' + name, method="POST", data=simplejson.dumps(query), headers=headers)
  File "/1/edward/src/openlibrary/openlibrary/api.py", line 48, in _request
    raise OLError(e)
OLError: Bad Request: duplicate key value violates unique constraint "version_thing_id_key"

I was trying to save this:

[{'authors': [<ref: u'/a/OL818321A'>],
  'by_statement': 'Hasan Hasani.',
  'created': datetime.datetime(2008, 4, 1, 3, 28, 50, 625462),
  'description': <text: u'das'>,
  'first_sentence': <text: u'sdasd'>,
  'genres': ['Dictionaries.'],
  'id': 5135390,
  'key': '/b/OL3633930M',
  'languages': [<ref: u'/l/alb'>],
  'last_modified': datetime.datetime(2009, 7, 5, 20, 54, 49, 625713),
  'latest_revision': 62,
  'lc_classifications': ['CS2377 .H38 2001'],
  'lccn': ['2002432668'],
  'notes': <text: u'xzzc'>,
  'number_of_pages': 222,
  'pagination': '222 p. ;',
  'publish_date': '2001',
  'publish_places': [u'Prishtine\u0308'],
  'publishers': [u'Shte\u0308pia Botuese Faik Konica'],
  'revision': 62,
  'subjects': ['Names, Personal -- Albanian -- Dictionaries.',
               'Children -- Albania.'],
  'table_of_contents': [{'class': 'subsection',
                         'type': <ref: u'/type/toc_item'>}],
  'title': u'5043 emra shqip pe\u0308r fe\u0308mije\u0308',
  'title_prefix': 'aa',
  'type': <ref: u'/type/edition'>,
  'works': [{'key': '/works/OL15112965W'}]}]