4198: Person view does not remove a row correctly when two people are merged.

This patch improves on the context changes:
 * avoid use of transaction_xx methods
 * force an abort in case of unclean transaction

Backward compatibility is broken to achieve this.


svn: r16680
This commit is contained in:
Benny Malengier
2011-02-20 10:52:06 +00:00
parent cce4013b44
commit 752d594571
47 changed files with 205 additions and 129 deletions

View File

@@ -51,6 +51,7 @@ from gui.utils import open_file_with_default_application
from gui.dbguielement import DbGUIElement
from gui.selectors import SelectorFactory
import gen.lib
from gen.db import DbTxn
import Utils
import ThumbNails
import Errors
@@ -476,8 +477,8 @@ class GalleryTab(ButtonTab, DbGUIElement):
basename = os.path.basename(name)
(root, ext) = os.path.splitext(basename)
photo.set_description(root)
with self.dbstate.db.transaction_begin(
_("Drag Media Object")) as trans:
with DbTxn(_("Drag Media Object"),
self.dbstate.db) as trans:
self.dbstate.db.add_object(photo, trans)
oref = gen.lib.MediaRef()
oref.set_reference_handle(photo.get_handle())

View File

@@ -42,6 +42,7 @@ import gtk
#-------------------------------------------------------------------------
import const
import gen.lib
from gen.db import DbTxn
import GrampsDisplay
from editprimary import EditPrimary
from objectentries import PlaceEntry
@@ -253,14 +254,14 @@ class EditEvent(EditPrimary):
return
if not self.obj.handle:
with self.db.transaction_begin(_("Add Event (%s)") %
self.obj.get_gramps_id()) as trans:
with DbTxn(_("Add Event (%s)") % self.obj.get_gramps_id(),
self.db) as trans:
self.db.add_event(self.obj, trans)
else:
orig = self.get_from_handle(self.obj.handle)
if cmp(self.obj.serialize(), orig.serialize()):
with self.db.transaction_begin(_("Edit Event (%s)") %
self.obj.get_gramps_id()) as trans:
with DbTxn(_("Edit Event (%s)") % self.obj.get_gramps_id(),
self.db) as trans:
if not self.obj.get_gramps_id():
self.obj.set_gramps_id(self.db.find_next_event_gramps_id())
self.commit_event(self.obj, trans)
@@ -331,8 +332,8 @@ class DeleteEventQuery(object):
self.family_list = family_list
def query_response(self):
with self.db.transaction_begin(_("Delete Event (%s)") %
self.event.get_gramps_id()) as trans:
with DbTxn(_("Delete Event (%s)") % self.event.get_gramps_id(),
self.db) as trans:
self.db.disable_signals()
ev_handle_list = [self.event.get_handle()]

View File

@@ -34,6 +34,7 @@ from gen.ggettext import gettext as _
#
#-------------------------------------------------------------------------
import gen.lib
from gen.db import DbTxn
from glade import Glade
from displaytabs import (SourceEmbedList, NoteTab, GalleryTab,
EventBackRefList, AttrEmbedList)
@@ -237,10 +238,10 @@ class EditEventRef(EditReference):
def ok_clicked(self, obj):
if self.source.handle:
with self.db.transaction_begin(_("Modify Event")) as trans:
with DbTxn(_("Modify Event"), self.db) as trans:
self.commit_event(self.source,trans)
else:
with self.db.transaction_begin(_("Add Event")) as trans:
with DbTxn(_("Add Event"), self.db) as trans:
self.add_event(self.source,trans)
self.source_ref.ref = self.source.handle

View File

@@ -62,6 +62,7 @@ import Utils
import config
from gen.display.name import displayer as name_displayer
import gen.lib
from gen.db import DbTxn
import Errors
import DateHandler
from glade import Glade
@@ -1060,7 +1061,7 @@ class EditFamily(EditPrimary):
self._cleanup_callbacks()
if not original and not self.object_is_empty():
with self.db.transaction_begin(_("Add Family")) as trans:
with DbTxn(_("Add Family"), self.db) as trans:
# find the father, add the family handle to the father
handle = self.obj.get_father_handle()
@@ -1086,7 +1087,7 @@ class EditFamily(EditPrimary):
self.db.add_family(self.obj, trans)
elif cmp(original.serialize(),self.obj.serialize()):
with self.db.transaction_begin(_("Edit Family")) as trans:
with DbTxn(_("Edit Family"), self.db) as trans:
self.fix_parent_handles(original.get_father_handle(),
self.obj.get_father_handle(), trans)

View File

@@ -43,6 +43,7 @@ import gtk
#-------------------------------------------------------------------------
from gui.utils import open_file_with_default_application
import gen.lib
from gen.db import DbTxn
import gen.mime
import ThumbNails
import Utils
@@ -288,7 +289,7 @@ class EditMedia(EditPrimary):
self.obj.set_path(Utils.get_unicode_path_from_file_chooser(path))
with self.db.transaction_begin() as trans:
with DbTxn('', self.db) as trans:
if not self.obj.get_handle():
self.db.add_object(self.obj, trans)
msg = _("Add Media Object (%s)") % self.obj.get_description()
@@ -335,7 +336,7 @@ class DeleteMediaQuery(object):
self.the_lists = the_lists
def query_response(self):
with self.db.transaction_begin(_("Remove Media Object")) as trans:
with DbTxn(_("Remove Media Object"), self.db) as trans:
self.db.disable_signals()
(person_list, family_list, event_list,

View File

@@ -47,6 +47,7 @@ import gen.mime
import ThumbNails
import Utils
from gen.lib import NoteType
from gen.db import DbTxn
from glade import Glade
from displaytabs import (SourceEmbedList, AttrEmbedList, MediaBackRefList,
NoteTab)
@@ -587,12 +588,12 @@ class EditMediaRef(EditReference):
def save(self,*obj):
#first save primary object
if self.source.handle:
with self.db.transaction_begin(_("Edit Media Object (%s)"
) % self.source.get_description()) as trans:
with DbTxn(_("Edit Media Object (%s)") %
self.source.get_description(), self.db) as trans:
self.db.commit_media_object(self.source, trans)
else:
with self.db.transaction_begin(_("Add Media Object (%s)"
) % self.source.get_description()) as trans:
with DbTxn(_("Add Media Object (%s)") %
self.source.get_description(), self.db) as trans:
self.db.add_object(self.source, trans)
#save reference object in memory

View File

@@ -53,6 +53,7 @@ from displaytabs import GrampsTab, NoteBackRefList
from gui.widgets import (MonitoredDataType, MonitoredCheckbox,
MonitoredEntry, PrivacyButton, MonitoredTagList)
from gen.lib import Note
from gen.db import DbTxn
from QuestionDialog import ErrorDialog
from glade import Glade
@@ -317,7 +318,7 @@ class EditNote(EditPrimary):
self.ok_button.set_sensitive(True)
return
with self.db.transaction_begin() as trans:
with DbTxn('', self.db) as trans:
if not self.obj.get_handle():
self.db.add_note(self.obj, trans)
msg = _("Add Note")
@@ -340,8 +341,8 @@ class DeleteNoteQuery(object):
self.the_lists = the_lists
def query_response(self):
with self.db.transaction_begin(_("Delete Note (%s)") %
self.note.get_gramps_id()) as trans:
with DbTxn(_("Delete Note (%s)") % self.note.get_gramps_id(),
self.db) as trans:
self.db.disable_signals()
(person_list, family_list, event_list, place_list, source_list,

View File

@@ -51,6 +51,7 @@ import pango
import Utils
from gui.utils import add_menuitem, open_file_with_default_application
import gen.lib
from gen.db import DbTxn
from gui import widgets
from gen.display.name import displayer as name_displayer
import Errors
@@ -868,7 +869,7 @@ class EditPerson(EditPrimary):
self.db.set_birth_death_index(self.obj)
with self.db.transaction_begin() as trans:
with DbTxn('', self.db) as trans:
self._update_family_ids()
if not self.obj.get_handle():
self.db.add_person(self.obj, trans)

View File

@@ -44,6 +44,7 @@ import gtk
#
#-------------------------------------------------------------------------
import gen.lib
from gen.db import DbTxn
from editprimary import EditPrimary
from displaytabs import (GrampsTab, LocationEmbedList, SourceEmbedList,
GalleryTab, NoteTab, WebEmbedList, PlaceBackRefList)
@@ -306,7 +307,7 @@ class EditPlace(EditPrimary):
self.ok_button.set_sensitive(True)
return
with self.db.transaction_begin() as trans:
with DbTxn('', self.db) as trans:
if not self.obj.get_handle():
self.db.add_place(self.obj, trans)
msg = _("Add Place (%s)") % self.obj.get_title()
@@ -338,8 +339,8 @@ class DeletePlaceQuery(object):
self.event_list = event_list
def query_response(self):
with self.db.transaction_begin(_("Delete Place (%s)") %
self.obj.get_title()) as trans:
with DbTxn(_("Delete Place (%s)") % self.obj.get_title(),
self.db) as trans:
self.db.disable_signals()
place_handle = self.obj.get_handle()

View File

@@ -34,6 +34,7 @@ from gen.ggettext import gettext as _
#
#-------------------------------------------------------------------------
from gen.lib import NoteType
from gen.db import DbTxn
from displaytabs import NoteTab,AddrEmbedList,WebEmbedList,SourceBackRefList
from gui.widgets import MonitoredEntry, PrivacyButton, MonitoredDataType
@@ -190,10 +191,10 @@ class EditRepoRef(EditReference):
def ok_clicked(self, obj):
if self.source.handle:
with self.db.transaction_begin(_("Modify Repository")) as trans:
with DbTxn(_("Modify Repository"), self.db) as trans:
self.db.commit_repository(self.source,trans)
else:
with self.db.transaction_begin(_("Add Repository")) as trans:
with DbTxn(_("Add Repository"), self.db) as trans:
self.db.add_repository(self.source,trans)
self.source_ref.ref = self.source.handle

View File

@@ -41,6 +41,7 @@ import gtk
#
#-------------------------------------------------------------------------
import gen.lib
from gen.db import DbTxn
from gui.widgets import MonitoredEntry, MonitoredDataType, PrivacyButton
from displaytabs import AddrEmbedList, WebEmbedList, NoteTab, SourceBackRefList
@@ -177,7 +178,7 @@ class EditRepository(EditPrimary):
self.ok_button.set_sensitive(True)
return
with self.db.transaction_begin() as trans:
with DbTxn('', self.db) as trans:
if not self.obj.get_handle():
self.db.add_repository(self.obj, trans)
msg = _("Add Repository (%s)") % self.obj.get_name()
@@ -198,8 +199,8 @@ class DeleteRepositoryQuery(object):
self.sources = sources
def query_response(self):
with self.db.transaction_begin(_("Delete Repository (%s)") %
self.obj.get_name()) as trans:
with DbTxn(_("Delete Repository (%s)") % self.obj.get_name(),
self.db) as trans:
repos_handle_list = [self.obj.get_handle()]

View File

@@ -43,6 +43,7 @@ import gtk
#
#-------------------------------------------------------------------------
import gen.lib
from gen.db import DbTxn
from editprimary import EditPrimary
from displaytabs import (NoteTab, GalleryTab, DataEmbedList,
@@ -195,7 +196,7 @@ class EditSource(EditPrimary):
self.ok_button.set_sensitive(True)
return
with self.db.transaction_begin() as trans:
with DbTxn('', self.db) as trans:
if not self.obj.get_handle():
self.db.add_source(self.obj, trans)
msg = _("Add Source (%s)") % self.obj.get_title()
@@ -216,8 +217,8 @@ class DeleteSrcQuery(object):
self.the_lists = the_lists
def query_response(self):
with self.db.transaction_begin(_("Delete Source (%s)") %
self.source.get_title()) as trans:
with DbTxn(_("Delete Source (%s)") % self.source.get_title(),
self.db) as trans:
self.db.disable_signals()
(person_list, family_list, event_list, place_list, source_list,

View File

@@ -34,6 +34,7 @@ from gen.ggettext import gettext as _
#
#-------------------------------------------------------------------------
import gen.lib
from gen.db import DbTxn
from glade import Glade
from displaytabs import (NoteTab, GalleryTab, SourceBackRefList,
DataEmbedList, RepoEmbedList)
@@ -206,10 +207,10 @@ class EditSourceRef(EditReference):
def ok_clicked(self, obj):
if self.source.handle:
with self.db.transaction_begin(_("Modify Source")) as trans:
with DbTxn(_("Modify Source"), self.db) as trans:
self.db.commit_source(self.source,trans)
else:
with self.db.transaction_begin(_("Add Source")) as trans:
with DbTxn(_("Add Source"), self.db) as trans:
self.db.add_source(self.source,trans)
if self.update: