diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 768005b92..440265545 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -11,6 +11,8 @@ * src/po/ru.po: Translation update. * doc/gramps-manual/Makefile.am: Remove existing link before creating a new one. + * src/ReadGrdb.py: Disable signals and request rebuild at the end; + properly set transaction. 2005-12-07 Don Allingham * src/Report.py: change from gtk.FILE_CHOOSER_CREATE_FOLDER to diff --git a/gramps2/src/ReadGrdb.py b/gramps2/src/ReadGrdb.py index e3a001545..2d3b548af 100644 --- a/gramps2/src/ReadGrdb.py +++ b/gramps2/src/ReadGrdb.py @@ -61,12 +61,17 @@ def importData(database, filename, callback=None,cl=0,use_trans=True): return if not other_database.version_supported(): if cl: - print "Error: %s could not be opened.\n%s Exiting." % (filename,\ - _("The database version is not supported by this version of GRAMPS.\n"\ - "Please upgrade to the corresponding version or use XML for porting data between different database versions.")) + print "Error: %s could not be opened.\n%s Exiting." \ + % (filename, + _("The database version is not supported " + "by this version of GRAMPS.\n"\ + "Please upgrade to the corresponding version " + "or use XML for porting data between different " + "database versions.")) else: ErrorDialog(_("%s could not be opened") % filename, - _("The Database version is not supported by this version of GRAMPS.")) + _("The Database version is not supported " + "by this version of GRAMPS.")) return # Check for duplicate handles. At the moment we simply exit here, @@ -102,9 +107,17 @@ def importData(database, filename, callback=None,cl=0,use_trans=True): if handles.intersection(other_handles): raise Errors.HandleError('Event handles in two databases overlap.') + # Proceed with preparing for import + if use_trans: + trans = database.transaction_begin() + trans.set_batch(True) + else: + trans = None + + database.disable_signals() + # copy all data from new_database to database, # rename gramps IDs of first-class objects when conflicts are found - trans = database.transaction_begin(_("Import database")) # People table for person_handle in other_database.person_map.keys(): @@ -168,4 +181,9 @@ def importData(database, filename, callback=None,cl=0,use_trans=True): # Events don't have gramps IDs, so we don't need to check here database.add_event(event,trans) + # close the other database and clean things up + other_database.close() + database.transaction_commit(trans,_("Import database")) + database.enable_signals() + database.request_rebuild()