Fix up book search to work with abbreviations

bzr-revno: 343
This commit is contained in:
Tim Bentley 2009-02-23 19:46:24 +00:00
parent 8a01d651c0
commit 814c9ad79a
2 changed files with 13 additions and 9 deletions

View File

@ -522,11 +522,11 @@ class BiblePlugin(Plugin, PluginUtils):
else:
start_chapter = chapter
else: # more complex
print search
#print search
sp = search.split("-") #find first
print sp, len(sp)
#print sp, len(sp)
sp1 = sp[0].split(":")
print sp1, len(sp1)
#print sp1, len(sp1)
if len(sp1) == 1:
start_chapter = sp1[0]
start_verse = 1
@ -538,7 +538,7 @@ class BiblePlugin(Plugin, PluginUtils):
end_verse = start_verse
else:
sp1 = sp[1].split(":")
print sp1, len(sp1)
#print sp1, len(sp1)
if len(sp1) == 1:
end_chapter = sp1[0]
end_verse = 1
@ -556,9 +556,9 @@ class BiblePlugin(Plugin, PluginUtils):
end_verse = 99
if start_chapter == "":
message = "No chapter found for search"
print "message = " + str(message)
print "search = " + str(original)
print "results = " + str(book) + " @ "+ str(start_chapter)+" @ "+ str(end_chapter)+" @ "+ str(start_verse)+ " @ "+ str(end_verse)
#print "message = " + str(message)
#print "search = " + str(original)
#print "results = " + str(book) + " @ "+ str(start_chapter)+" @ "+ str(end_chapter)+" @ "+ str(start_verse)+ " @ "+ str(end_verse)
if message == None:
self.search_results = None

View File

@ -147,7 +147,10 @@ class BibleDBImpl(BibleCommon):
def get_bible_book(self, bookname):
log.debug( "get_bible_book %s", bookname)
return self.session.query(Book).filter_by(name = bookname).first()
bk = self.session.query(Book).filter(Book.name.like(bookname+u"%")).first()
if bk == None:
bk = self.session.query(Book).filter(Book.abbreviation.like(bookname+u"%")).first()
return bk
def get_bible_chapter(self, id, chapter):
log.debug( "get_bible_chapter %s,%s", id, chapter )
@ -157,7 +160,8 @@ class BibleDBImpl(BibleCommon):
def get_bible_text(self, bookname, chapter, sverse, everse):
log.debug( "get_bible_text %s,%s,%s,%s ", bookname, chapter, sverse, everse)
metadata.bind.echo = False
s = text (""" select name,chapter,verse.verse, verse.text FROM verse , book where verse.book_id == book.id AND verse.chapter == :c AND (verse.verse between :v1 and :v2) and book.name == :b """)
bookname = bookname + u"%"
s = text (""" select name,chapter,verse.verse, verse.text FROM verse , book where verse.book_id == book.id AND verse.chapter == :c AND (verse.verse between :v1 and :v2) and (book.name like :b) """)
return self.db.execute(s, c=chapter, v1=sverse , v2=everse, b=bookname).fetchall()
def get_verses_from_text(self,versetext):