Fix multi bible searches

bzr-revno: 53
This commit is contained in:
Tim Bentley 2008-10-29 21:06:22 +00:00
parent 91e388763e
commit 06ed511d67
3 changed files with 10 additions and 4 deletions

View File

@ -179,6 +179,11 @@ class BibleDBImpl:
s = text (""" select text FROM verse,book where verse.book_id == book.id AND verse.chapter == :c and verse.verse == :v and book.name == :b """)
return self.db.execute(s, c=chapter, v=verse , b=bookname).fetchone()
def getBibleText(self, bookname, chapter, sverse, everse):
metadata.bind.echo = True
s = text (""" select 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 """)
return self.db.execute(s, c=chapter, v1=sverse , v2=everse, b=bookname).fetchall()
def _cleanText(self, text):
text = text.replace('\n', '')
text = text.replace('\r', '')

View File

@ -98,7 +98,8 @@ class BibleManager:
then only one verse is returned
"""
if everse < sverse:
everse = sverse # make sure end after we start. Also optional
text = self.biblelist[bible].getBibleText(book, chapter, sverse)
text = self.biblelist[bible].getBibleText(book, chapter, sverse)
else:
text = self.biblelist[bible].getBibleText(book, chapter, sverse, everse)
print text
return text

View File

@ -62,9 +62,9 @@ class TestBibleManager(unittest.TestCase):
def testGetVerseText(self):
print "testGetVerseText"
c = self.bm.getVerseText("TheMessage",'"Genesis"',1,2,1)
c = self.bm.getVerseText("TheMessage",'Genesis',1,1,1)
print c
c = self.bm.getVerseText("NIV",'"Genesis"',1,2,1)
c = self.bm.getVerseText("NIV",'Genesis',1,1,3)
print c
if __name__ == '__main__':