Rename method to save_object()

This commit is contained in:
Jon Tibble 2010-06-28 14:38:29 +01:00
parent ad9328a30f
commit 3be57e57e7
8 changed files with 25 additions and 25 deletions

View File

@ -135,7 +135,7 @@ class Manager(object):
settings.endGroup()
self.session = init_schema(self.db_url)
def insert_object(self, object_instance):
def save_object(self, object_instance):
"""
Save an object to the database

View File

@ -98,7 +98,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
else:
alert = AlertItem()
alert.text = unicode(self.AlertTextEdit.text())
self.manager.insert_object(alert)
self.manager.save_object(alert)
self.AlertTextEdit.setText(u'')
self.loadList()
@ -109,7 +109,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
if self.item_id:
alert = self.manager.get_object(AlertItem, self.item_id)
alert.text = unicode(self.AlertTextEdit.text())
self.manager.insert_object(alert)
self.manager.save_object(alert)
self.item_id = None
self.loadList()
else:

View File

@ -200,9 +200,9 @@ class BibleDB(QtCore.QObject, Manager):
"""
self.wizard = wizard
self.create_meta(u'dbversion', u'2')
self.insert_object(Testament.populate(name=u'Old Testament'))
self.insert_object(Testament.populate(name=u'New Testament'))
self.insert_object(Testament.populate(name=u'Apocrypha'))
self.save_object(Testament.populate(name=u'Old Testament'))
self.save_object(Testament.populate(name=u'New Testament'))
self.save_object(Testament.populate(name=u'Apocrypha'))
return self.name
def create_book(self, name, abbrev, testament=1):
@ -221,7 +221,7 @@ class BibleDB(QtCore.QObject, Manager):
log.debug(u'create_book %s,%s', name, abbrev)
book = Book.populate(name=name, abbreviation=abbrev,
testament_id=testament)
self.insert_object(book)
self.save_object(book)
return book
def create_chapter(self, book_id, chapter, textlist):
@ -289,7 +289,7 @@ class BibleDB(QtCore.QObject, Manager):
The value for this instance
"""
log.debug(u'save_meta %s/%s', key, value)
self.insert_object(BibleMeta.populate(key=key, value=value))
self.save_object(BibleMeta.populate(key=key, value=value))
def get_book(self, book):
"""

View File

@ -166,7 +166,7 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
u'utf-8')
self.customSlide.theme_name = unicode(self.ThemeComboBox.currentText(),
u'utf-8')
return self.custommanager.insert_object(self.customSlide)
return self.custommanager.save_object(self.customSlide)
def onUpButtonPressed(self):
selectedRow = self.VerseListView.currentRow()

View File

@ -290,7 +290,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
author = Author.populate(first_name=text.rsplit(u' ', 1)[0],
last_name=text.rsplit(u' ', 1)[1], display_name=text)
self.songmanager.insert_object(author)
self.songmanager.save_object(author)
self.song.authors.append(author)
author_item = QtGui.QListWidgetItem(
unicode(author.display_name))
@ -342,7 +342,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
topic = Topic.populate(name=text)
self.songmanager.insert_object(topic)
self.songmanager.save_object(topic)
self.song.topics.append(topic)
topic_item = QtGui.QListWidgetItem(unicode(topic.name))
topic_item.setData(QtCore.Qt.UserRole,
@ -392,7 +392,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
book = Book.populate(name=text)
self.songmanager.insert_object(book)
self.songmanager.save_object(book)
self.song.book = book
self.loadBooks()
else:
@ -631,7 +631,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
if self._validate_song():
self.processLyrics()
self.processTitle()
self.songmanager.insert_object(self.song)
self.songmanager.save_object(self.song)
return True
return False

View File

@ -131,7 +131,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
first_name=unicode(self.authorform.FirstNameEdit.text()),
last_name=unicode(self.authorform.LastNameEdit.text()),
display_name=unicode(self.authorform.DisplayEdit.text()))
if self.songmanager.insert_object(author):
if self.songmanager.save_object(author):
self.resetAuthors()
else:
QtGui.QMessageBox.critical(
@ -143,7 +143,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
def onTopicAddButtonClick(self):
if self.topicform.exec_():
topic = Topic.populate(name=unicode(self.topicform.NameEdit.text()))
if self.songmanager.insert_object(topic):
if self.songmanager.save_object(topic):
self.resetTopics()
else:
QtGui.QMessageBox.critical(
@ -157,7 +157,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
book = Book.populate(
name=unicode(self.bookform.NameEdit.text()),
publisher=unicode(self.bookform.PublisherEdit.text()))
if self.songmanager.insert_object(book):
if self.songmanager.save_object(book):
self.resetBooks()
else:
QtGui.QMessageBox.critical(
@ -187,7 +187,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
author.last_name = unicode(self.authorform.LastNameEdit.text())
author.display_name = unicode(
self.authorform.DisplayEdit.text())
if self.songmanager.insert_object(author):
if self.songmanager.save_object(author):
self.resetAuthors()
else:
QtGui.QMessageBox.critical(
@ -203,7 +203,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
self.topicform.NameEdit.setText(topic.name)
if self.topicform.exec_(False):
topic.name = unicode(self.topicform.NameEdit.text())
if self.songmanager.insert_object(topic):
if self.songmanager.save_object(topic):
self.resetTopics()
else:
QtGui.QMessageBox.critical(
@ -221,7 +221,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
if self.bookform.exec_(False):
book.name = unicode(self.bookform.NameEdit.text())
book.publisher = unicode(self.bookform.PublisherEdit.text())
if self.songmanager.insert_object(book):
if self.songmanager.save_object(book):
self.resetBooks()
else:
QtGui.QMessageBox.critical(

View File

@ -309,7 +309,7 @@ class SongImport(object):
author.display_name = authortext
author.last_name = authortext.split(u' ')[-1]
author.first_name = u' '.join(authortext.split(u' ')[:-1])
self.manager.insert_object(author)
self.manager.save_object(author)
song.authors.append(author)
if self.song_book_name:
filter_string = u'name=%s' % self.song_book_name
@ -318,7 +318,7 @@ class SongImport(object):
song_book = Book()
song_book.name = self.song_book_name
song_book.publisher = self.song_book_pub
self.manager.insert_object(song_book)
self.manager.save_object(song_book)
song.song_book_id = song_book.id
for topictext in self.topics:
filter_string = u'name=%s' % topictext
@ -326,9 +326,9 @@ class SongImport(object):
if topic is None:
topic = Topic()
topic.name = topictext
self.manager.insert_object(topic)
self.manager.save_object(topic)
song.topics.append(topictext)
self.manager.insert_object(song)
self.manager.save_object(song)
def print_song(self):
"""

View File

@ -148,7 +148,7 @@ class SongUsagePlugin(Plugin):
song_usage_item.authors = u''
for author in audit[1]:
song_usage_item.authors += author + u' '
self.songusagemanager.insert_object(song_usage_item)
self.songusagemanager.save_object(song_usage_item)
def onSongUsageDelete(self):
self.SongUsagedeleteform.exec_()