implemented search-person

This commit is contained in:
Péter Henrik Gombos 2011-10-08 19:53:24 +00:00
parent a9f1ac6a66
commit 4449493bbd

View File

@ -7,8 +7,6 @@ import pgdb
from fileformat import read_actionlist, write_actionlist
from util import *
file_encoding = 'utf8'
# connection = pgdb.connect(database='oysteini_pbb2',
# user='oysteini_pbb',
# password='lio5Aide',
@ -215,7 +213,7 @@ def show(connection, ids, commit_format=False, tmp_file=False):
else:
output = '\n'.join(objects)
if tmp_file:
filename = write_tmpfile('.'.join(ids), output, file_encoding)
filename = write_tmpfile('.'.join(ids), output)
print filename
return filename
else:
@ -277,7 +275,15 @@ def search_book(connection, search_strings, search_description=False):
def search_person(connection, search_strings):
pass
c = connection.cursor()
result_strings = []
for s in search_strings:
for i in range(3):
result_strings.append(s)
c.execute('SELECT * FROM person LEFT JOIN bookperson ON person.id=bookperson.person WHERE person.lastname ILIKE %s or person.firstname ILIKE %s OR person.id ILIKE %s', result_strings)
for i in xrange(c.rowcount):
person = fetchone_dict(c)
print person['lastname'], ', ', person['firstname'], '\t', person['book']
def do_action(connection, action):
print 'ACTION %s ' % action
@ -289,7 +295,7 @@ def do_action(connection, action):
'new-category': q_new_category,
'edit-category': q_edit_category}
action_type = action['action']
execute_query(c, queries[action_type], action)
c.execute(queries[action_type], action)
if action_type in ['new-book', 'edit-book']:
print 'FIXING PERSONS: REMOVING'
c.execute(q_remove_bookpersons, {'isbn': action['isbn']})
@ -329,10 +335,7 @@ def commit(connection, filename=None):
commit_actions(connection, actions)
def edit(connection, ids):
filename = show(connection, ids, commit_format=True, tmp_file=True)
print filename
run_editor(filename)
commit(connection, filename)
pass
def map_cmd(connection, shelfname=None, category=None):
pass