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:
@@ -50,6 +50,7 @@ LOG = logging.getLogger(".ImportCSV")
|
||||
from gen.ggettext import sgettext as _
|
||||
from gen.ggettext import ngettext
|
||||
import gen.lib
|
||||
from gen.db import DbTxn
|
||||
from QuestionDialog import ErrorDialog
|
||||
from DateHandler import parser as _dp
|
||||
from Utils import gender as gender_map
|
||||
@@ -438,8 +439,7 @@ class CSVParser(object):
|
||||
progress.set_pass(_('Reading data...'), 1)
|
||||
data = self.readCSV()
|
||||
progress.set_pass(_('Importing data...'), len(data))
|
||||
with self.db.transaction_begin(_("CSV import"), batch=True
|
||||
) as self.trans:
|
||||
with DbTxn(_("CSV import"), self.db, batch=True) as self.trans:
|
||||
self.db.disable_signals()
|
||||
t = time.time()
|
||||
self.lineno = 0
|
||||
|
||||
@@ -48,6 +48,7 @@ LOG = logging.getLogger(".ImportGeneWeb")
|
||||
#-------------------------------------------------------------------------
|
||||
import Errors
|
||||
import gen.lib
|
||||
from gen.db import DbTxn
|
||||
from QuestionDialog import ErrorDialog
|
||||
from htmlentitydefs import name2codepoint
|
||||
|
||||
@@ -112,8 +113,7 @@ class GeneWebParser(object):
|
||||
return line
|
||||
|
||||
def parse_geneweb_file(self):
|
||||
with self.db.transaction_begin(_("GeneWeb import"), batch=True
|
||||
) as self.trans:
|
||||
with DbTxn(_("GeneWeb import"), self.db, batch=True) as self.trans:
|
||||
self.db.disable_signals()
|
||||
t = time.time()
|
||||
self.lineno = 0
|
||||
|
||||
@@ -50,6 +50,7 @@ log = logging.getLogger('.ImportProGen')
|
||||
import Utils
|
||||
from gui.utils import ProgressMeter
|
||||
import gen.lib
|
||||
from gen.db import DbTxn
|
||||
from QuestionDialog import ErrorDialog
|
||||
|
||||
class ProgenError(Exception):
|
||||
@@ -495,8 +496,7 @@ class ProgenParser(object):
|
||||
self.pers = _read_recs(self.def_['Table_1'], self.bname)
|
||||
self.rels = _read_recs(self.def_['Table_2'], self.bname)
|
||||
|
||||
with self.db.transaction_begin(_("Pro-Gen import"), batch=True
|
||||
) as self.trans:
|
||||
with DbTxn(_("Pro-Gen import"), self.db, batch=True) as self.trans:
|
||||
self.db.disable_signals()
|
||||
|
||||
self.create_persons()
|
||||
|
||||
@@ -48,6 +48,7 @@ LOG = logging.getLogger(".ImportVCard")
|
||||
#-------------------------------------------------------------------------
|
||||
import Errors
|
||||
import gen.lib
|
||||
from gen.db import DbTxn
|
||||
from QuestionDialog import ErrorDialog
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@@ -90,8 +91,7 @@ class VCardParser(object):
|
||||
return line
|
||||
|
||||
def parse_vCard_file(self):
|
||||
with self.db.transaction_begin(_("vCard import"), batch=True
|
||||
) as self.trans:
|
||||
with DbTxn(_("vCard import"), self.db, batch=True) as self.trans:
|
||||
self.db.disable_signals()
|
||||
t = time.time()
|
||||
self.person = None
|
||||
|
||||
@@ -43,6 +43,7 @@ LOG = logging.getLogger(".ImportXML")
|
||||
from QuestionDialog import ErrorDialog, WarningDialog
|
||||
import gen.mime
|
||||
import gen.lib
|
||||
from gen.db import DbTxn
|
||||
import Utils
|
||||
import DateHandler
|
||||
from gen.display.name import displayer as name_displayer
|
||||
@@ -771,8 +772,8 @@ class GrampsParser(UpdateCallback):
|
||||
no_magic = True
|
||||
else:
|
||||
no_magic = False
|
||||
with self.db.transaction_begin(_("Gramps XML import"), batch=True,
|
||||
no_magic=no_magic) as self.trans:
|
||||
with DbTxn(_("Gramps XML import"), self.db, batch=True,
|
||||
no_magic=no_magic) as self.trans:
|
||||
self.set_total(linecount)
|
||||
|
||||
self.db.disable_signals()
|
||||
|
||||
@@ -113,6 +113,7 @@ LOG = logging.getLogger(".libgedcom")
|
||||
import Errors
|
||||
import const
|
||||
import gen.lib
|
||||
from gen.db import DbTxn
|
||||
from gen.updatecallback import UpdateCallback
|
||||
import gen.mime
|
||||
import LdsUtils
|
||||
@@ -2281,8 +2282,8 @@ class GedcomParser(UpdateCallback):
|
||||
Parses the opened GEDCOM file.
|
||||
"""
|
||||
no_magic = self.maxpeople < 1000
|
||||
with self.dbase.transaction_begin(_("GEDCOM import"), not use_trans,
|
||||
no_magic) as self.trans:
|
||||
with DbTxn(_("GEDCOM import"), self.dbase, not use_trans, no_magic
|
||||
) as self.trans:
|
||||
|
||||
self.dbase.disable_signals()
|
||||
self.__parse_header_head()
|
||||
|
||||
@@ -47,6 +47,7 @@ _LOG = logging.getLogger(".gui.personview")
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gen.lib
|
||||
from gen.db import DbTxn
|
||||
from gui.views.listview import ListView
|
||||
import Utils
|
||||
from gen.display.name import displayer as name_displayer
|
||||
@@ -305,7 +306,7 @@ class BasePersonView(ListView):
|
||||
self.uistate.set_busy_cursor(True)
|
||||
|
||||
# create the transaction
|
||||
with self.dbstate.db.transaction_begin() as trans:
|
||||
with DbTxn('', self.dbstate.db) as trans:
|
||||
|
||||
# create name to save
|
||||
person = self.active_person
|
||||
|
||||
@@ -37,7 +37,7 @@ import gtk
|
||||
# gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.db import find_surname_name
|
||||
from gen.db import find_surname_name, DbTxn
|
||||
import const
|
||||
from gui.utils import ProgressMeter
|
||||
import GrampsDisplay
|
||||
@@ -231,8 +231,8 @@ class ChangeNames(tool.BatchTool, ManagedWindow.ManagedWindow):
|
||||
GrampsDisplay.help(WIKI_HELP_PAGE , WIKI_HELP_SEC)
|
||||
|
||||
def on_ok_clicked(self, obj):
|
||||
with self.db.transaction_begin(_("Capitalization changes"),batch=True
|
||||
) as self.trans:
|
||||
with DbTxn(_("Capitalization changes"), self.db, batch=True
|
||||
) as self.trans:
|
||||
self.db.disable_signals()
|
||||
changelist = set(self.model.get_value(node,1)
|
||||
for node in self.iter_list
|
||||
|
||||
@@ -42,6 +42,7 @@ import locale
|
||||
import ManagedWindow
|
||||
import AutoComp
|
||||
from gen.lib import EventType
|
||||
from gen.db import DbTxn
|
||||
from QuestionDialog import OkDialog
|
||||
from gui.plug import tool
|
||||
from glade import Glade
|
||||
@@ -110,8 +111,7 @@ class ChangeTypes(tool.BatchTool, ManagedWindow.ManagedWindow):
|
||||
|
||||
modified = 0
|
||||
|
||||
with self.db.transaction_begin(_('Change types'), batch=True
|
||||
) as self.trans:
|
||||
with DbTxn(_('Change types'), self.db, batch=True) as self.trans:
|
||||
self.db.disable_signals()
|
||||
if not cli:
|
||||
progress = ProgressMeter(_('Analyzing Events'),'')
|
||||
|
||||
@@ -59,6 +59,7 @@ import gtk
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gen.lib
|
||||
from gen.db import DbTxn
|
||||
import Utils
|
||||
from gui.utils import ProgressMeter
|
||||
import ManagedWindow
|
||||
@@ -174,8 +175,7 @@ class Check(tool.BatchTool):
|
||||
if self.db.__class__.__name__ == 'DbBsddb':
|
||||
low_level(self.db)
|
||||
|
||||
with self.db.transaction_begin(_("Check Integrity"), batch=True
|
||||
) as trans:
|
||||
with DbTxn(_("Check Integrity"), self.db, batch=True) as trans:
|
||||
self.db.disable_signals()
|
||||
checker = CheckIntegrity(dbstate, uistate, trans)
|
||||
checker.fix_encoding()
|
||||
|
||||
@@ -44,6 +44,7 @@ from gen.ggettext import gettext as _
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gen.lib
|
||||
from gen.db import DbTxn
|
||||
from gui.plug import tool
|
||||
from gui.utils import ProgressMeter
|
||||
from QuestionDialog import QuestionDialog
|
||||
@@ -155,8 +156,7 @@ class DateParserDisplayTest(tool.Tool):
|
||||
# (4,7,1789,False,5,88,1876,False),"Text comment")
|
||||
#dates.append( d)
|
||||
|
||||
with self.db.transaction_begin(_("Date Test Plugin"),batch=True
|
||||
) as trans:
|
||||
with DbTxn(_("Date Test Plugin"), self.db, batch=True) as trans:
|
||||
self.db.disable_signals()
|
||||
self.progress.set_pass(_('Generating dates'),
|
||||
len(dates))
|
||||
|
||||
@@ -45,6 +45,7 @@ from gen.ggettext import ngettext
|
||||
#-------------------------------------------------------------------------
|
||||
import ManagedWindow
|
||||
import gen.lib
|
||||
from gen.db import DbTxn
|
||||
import Utils
|
||||
|
||||
from gui.plug import tool
|
||||
@@ -78,8 +79,7 @@ class EventNames(tool.BatchTool, ManagedWindow.ManagedWindow):
|
||||
"""
|
||||
Perform the actual extraction of information.
|
||||
"""
|
||||
with self.db.transaction_begin(_("Event name changes"), batch=True
|
||||
) as trans:
|
||||
with DbTxn(_("Event name changes"), self.db, batch=True) as trans:
|
||||
self.db.disable_signals()
|
||||
self.change = False
|
||||
counter = 0
|
||||
|
||||
@@ -46,6 +46,7 @@ import gobject
|
||||
# gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.db import DbTxn
|
||||
import ManagedWindow
|
||||
import GrampsDisplay
|
||||
|
||||
@@ -591,8 +592,7 @@ class ExtractCity(tool.BatchTool, ManagedWindow.ManagedWindow):
|
||||
GrampsDisplay.help()
|
||||
|
||||
def on_ok_clicked(self, obj):
|
||||
with self.db.transaction_begin(_("Extract Place data"), batch=True
|
||||
) as self.trans:
|
||||
with DbTxn(_("Extract Place data"), self.db, batch=True) as self.trans:
|
||||
self.db.disable_signals()
|
||||
changelist = [node for node in self.iter_list
|
||||
if self.model.get_value(node, 0)]
|
||||
|
||||
@@ -53,6 +53,7 @@ import GrampsDisplay
|
||||
import Assistant
|
||||
import Errors
|
||||
from gen.lib import MediaObject
|
||||
from gen.db import DbTxn
|
||||
from gen.updatecallback import UpdateCallback
|
||||
from gui.plug import tool
|
||||
from Utils import media_path_full, relative_path, media_path
|
||||
@@ -359,7 +360,7 @@ class BatchOp(UpdateCallback):
|
||||
Should not be overridden without good reasons.
|
||||
"""
|
||||
self.db.disable_signals()
|
||||
with self.db.transaction_begin("", batch=True) as self.trans:
|
||||
with DbTxn("", self.db, batch=True) as self.trans:
|
||||
success = self._run()
|
||||
trans.set_description(self.title)
|
||||
self.db.enable_signals()
|
||||
|
||||
@@ -56,6 +56,7 @@ import GrampsDisplay
|
||||
from gen.ggettext import sgettext as _
|
||||
from glade import Glade
|
||||
from gen.lib import Tag
|
||||
from gen.db import DbTxn
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@@ -242,7 +243,7 @@ class NotRelated(tool.ActivePersonTool, ManagedWindow.ManagedWindow) :
|
||||
tag_name = self.tagcombo.get_active_text()
|
||||
|
||||
# start the db transaction
|
||||
with self.db.transaction_begin("Tag not related") as transaction:
|
||||
with DbTxn("Tag not related", self.db) as transaction:
|
||||
|
||||
tag = self.db.get_tag_from_name(tag_name)
|
||||
if not tag:
|
||||
|
||||
@@ -51,6 +51,7 @@ from QuestionDialog import OkDialog
|
||||
import ManagedWindow
|
||||
import GrampsDisplay
|
||||
import gen.lib
|
||||
from gen.db import DbTxn
|
||||
from gen.ggettext import sgettext as _
|
||||
from glade import Glade
|
||||
|
||||
@@ -481,8 +482,8 @@ class PatchNames(tool.BatchTool, ManagedWindow.ManagedWindow):
|
||||
GrampsDisplay.help(webpage=WIKI_HELP_PAGE, section=WIKI_HELP_SEC)
|
||||
|
||||
def on_ok_clicked(self, obj):
|
||||
with self.db.transaction_begin(_("Extract information from names"),
|
||||
batch=True) as trans:
|
||||
with DbTxn(_("Extract information from names"), self.db, batch=True
|
||||
) as trans:
|
||||
self.db.disable_signals()
|
||||
|
||||
for key, data in self.handle_to_action.items():
|
||||
|
||||
@@ -54,6 +54,7 @@ import gobject
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.db import DbTxn
|
||||
import Errors
|
||||
import ManagedWindow
|
||||
from DateHandler import displayer as _dd
|
||||
@@ -279,8 +280,7 @@ class RemoveUnused(tool.Tool, ManagedWindow.ManagedWindow, UpdateCallback):
|
||||
self.reset()
|
||||
|
||||
def do_remove(self, obj):
|
||||
with self.db.transaction_begin(_("Remove unused objects"),
|
||||
batch=False) as trans:
|
||||
with DbTxn(_("Remove unused objects"), self.db, batch=False) as trans:
|
||||
self.db.disable_signals()
|
||||
|
||||
for row_num in range(len(self.real_model)-1, -1, -1):
|
||||
|
||||
@@ -42,6 +42,7 @@ from gen.ggettext import gettext as _
|
||||
#------------------------------------------------------------------------
|
||||
from gui.utils import ProgressMeter
|
||||
import gen.lib
|
||||
from gen.lib import DbTxn
|
||||
from gui.plug import tool
|
||||
|
||||
_findint = re.compile('^[^\d]*(\d+)[^\d]*')
|
||||
@@ -67,8 +68,7 @@ class ReorderIds(tool.BatchTool):
|
||||
else:
|
||||
print "Reordering Gramps IDs..."
|
||||
|
||||
with db.transaction_begin(_("Reorder Gramps IDs"), batch=True
|
||||
) as self.trans:
|
||||
with DbTxn(_("Reorder Gramps IDs"), db, batch=True) as self.trans:
|
||||
db.disable_signals()
|
||||
|
||||
if uistate:
|
||||
|
||||
@@ -37,6 +37,7 @@ from gen.ggettext import gettext as _
|
||||
#-------------------------------------------------------------------------
|
||||
import Sort
|
||||
|
||||
from gen.db import DbTxn
|
||||
from gui.plug import MenuToolOptions, PluginWindows
|
||||
from gen.plug.report import utils as ReportUtils
|
||||
from gen.plug.menu import FilterOption, PersonOption, \
|
||||
@@ -95,8 +96,7 @@ class SortEvents(PluginWindows.ToolManagedWindowBatch):
|
||||
self.sort_name = sort_functions[sort_func_num][0]
|
||||
self.sort_func = sort_functions[sort_func_num][1]
|
||||
self.sort = Sort.Sort(self.db)
|
||||
with self.db.transaction_begin(_("Sort event changes"), batch=True
|
||||
) as trans:
|
||||
with DbTxn(_("Sort event changes"), self.db, batch=True) as trans:
|
||||
self.db.disable_signals()
|
||||
family_handles = self.sort_person_events(trans)
|
||||
if len(family_handles) > 0:
|
||||
|
||||
@@ -59,6 +59,7 @@ import Utils
|
||||
import Bookmarks
|
||||
import gen.mime
|
||||
import gen.lib
|
||||
from gen.db import DbTxn
|
||||
from gui.editors import EditMedia, DeleteMediaQuery
|
||||
import Errors
|
||||
from Filters.SideBar import MediaSidebarFilter
|
||||
@@ -206,8 +207,7 @@ class MediaView(ListView):
|
||||
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)
|
||||
widget.emit_stop_by_name('drag_data_received')
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ import pango
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gen.lib
|
||||
from gen.db import DbTxn
|
||||
from gui.views.navigationview import NavigationView
|
||||
from gui.editors import EditPerson, EditFamily
|
||||
from gui.filtereditor import FilterEditor
|
||||
@@ -1500,8 +1501,7 @@ class RelationshipView(NavigationView):
|
||||
family = self.dbstate.db.get_family_from_handle(family_handle)
|
||||
family.add_child_ref(ref)
|
||||
|
||||
with self.dbstate.db.transaction_begin(_("Add Child to Family")
|
||||
) as trans:
|
||||
with DbTxn(_("Add Child to Family"), self.dbstate.db) as trans:
|
||||
#add parentref to child
|
||||
person.add_parent_family_handle(family_handle)
|
||||
#default relationship is used
|
||||
|
||||
Reference in New Issue
Block a user