From cc4eadc885ba403d79a0f1f13a443a6082716aa4 Mon Sep 17 00:00:00 2001 From: gombos Date: Sun, 9 Oct 2011 18:08:01 +0000 Subject: [PATCH] fixed bug in referenceadding to books --- cli/worblehat.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cli/worblehat.py b/cli/worblehat.py index 821912e..45ea697 100755 --- a/cli/worblehat.py +++ b/cli/worblehat.py @@ -85,7 +85,7 @@ q_edit_category = \ 'WHERE id=%(id)s' q_add_bookreference = \ 'INSERT INTO bookreference (book, reftype, value) ' \ - 'VALUES (%(isbn)s, %(reftype)s, %(value))' + 'VALUES (%(isbn)s, %(reftype)s, %(value)s)' def connect_to_db(): connection = pgdb.connect(database='oysteini_pbb2', @@ -313,11 +313,11 @@ def do_action(connection, action): 'relation': relation}) if action['references']: c.execute('SELECT referencetype.id FROM referencetype') - refs = c.fetchone() + legal_reftypes = [a for list in c.fetchall() for a in list] for (reftype, reflist) in action['references'].items(): for ref in reflist: - if ref in refs: - c.execute(q_add_reference, + if reftype in legal_reftypes: + c.execute(q_add_bookreference, {'isbn': action['isbn'], 'reftype': reftype, 'value': ref})