- fixed a traceback which occurred when performing a text search but no bible is available

bzr-revno: 1549
This commit is contained in:
Andreas Preikschat 2011-05-16 13:13:57 +02:00
commit b92d437a8d
2 changed files with 13 additions and 4 deletions

View File

@ -401,7 +401,7 @@ class BibleDB(QtCore.QObject, Manager):
"""
log.debug(u'BibleDB.get_chapter_count("%s")', book)
count = self.session.query(Verse.chapter).join(Book)\
.filter(Book.name==book)\
.filter(Book.name == book)\
.distinct().count()
if not count:
return 0
@ -420,8 +420,8 @@ class BibleDB(QtCore.QObject, Manager):
"""
log.debug(u'BibleDB.get_verse_count("%s", %s)', book, chapter)
count = self.session.query(Verse).join(Book)\
.filter(Book.name==book)\
.filter(Verse.chapter==chapter)\
.filter(Book.name == book)\
.filter(Verse.chapter == chapter)\
.count()
if not count:
return 0

View File

@ -285,7 +285,7 @@ class BibleManager(object):
Does a verse search for the given bible and text.
``bible``
The bible to seach in (unicode).
The bible to search in (unicode).
``second_bible``
The second bible (unicode). We do not search in this bible.
@ -294,6 +294,15 @@ class BibleManager(object):
The text to search for (unicode).
"""
log.debug(u'BibleManager.verse_search("%s", "%s")', bible, text)
if not bible:
Receiver.send_message(u'openlp_information_message', {
u'title': translate('BiblesPlugin.BibleManager',
'No Bibles Available'),
u'message': translate('BiblesPlugin.BibleManager',
'There are no Bibles currently installed. Please use the '
'Import Wizard to install one or more Bibles.')
})
return None
# Check if the bible or second_bible is a web bible.
webbible = self.db_cache[bible].get_object(BibleMeta,
u'download source')