diff --git a/gramps/plugins/database/bsddb_support/write.py b/gramps/plugins/database/bsddb_support/write.py index 46430ee85..65bf71980 100644 --- a/gramps/plugins/database/bsddb_support/write.py +++ b/gramps/plugins/database/bsddb_support/write.py @@ -2472,6 +2472,18 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback): _("Version"): bsddb_version, } + def prepare_import(self): + """ + Initialization before imports + """ + pass + + def commit_import(self): + """ + Post process after imports + """ + pass + def mk_backup_name(database, base): """ Return the backup name of the database table diff --git a/gramps/plugins/database/dictionarydb.py b/gramps/plugins/database/dictionarydb.py index 38ad398ac..44e3721fa 100644 --- a/gramps/plugins/database/dictionarydb.py +++ b/gramps/plugins/database/dictionarydb.py @@ -1810,3 +1810,16 @@ class DictionaryDb(DbWriteBase, DbReadBase, UpdateCallback, Callback): def rebuild_secondary(self, update): ## FIXME pass + + def prepare_import(self): + """ + Initialization before imports + """ + pass + + def commit_import(self): + """ + Post process after imports + """ + pass + diff --git a/gramps/plugins/database/djangodb.py b/gramps/plugins/database/djangodb.py index ca55eb0b1..f7fe47892 100644 --- a/gramps/plugins/database/djangodb.py +++ b/gramps/plugins/database/djangodb.py @@ -518,7 +518,7 @@ class DbDjango(DbWriteBase, DbReadBase, UpdateCallback, Callback): self.dji.add_tag_detail(obj.serialize()) self.use_import_cache = False self.import_cache = {} - self.dji.update_publics() + self.request_rebuild() def transaction_commit(self, txn): pass diff --git a/gramps/plugins/importer/importcsv.py b/gramps/plugins/importer/importcsv.py index 4c1e61764..44f7d29ed 100644 --- a/gramps/plugins/importer/importcsv.py +++ b/gramps/plugins/importer/importcsv.py @@ -103,8 +103,10 @@ def importData(dbase, filename, user): parser = CSVParser(dbase, user, (config.get('preferences.tag-on-import-format') if config.get('preferences.tag-on-import') else None)) try: + dbase.prepare_import() with open(filename, 'r') as filehandle: parser.parse(filehandle) + dbase.commit_import() except EnvironmentError as err: user.notify_error(_("%s could not be opened\n") % filename, str(err)) return diff --git a/gramps/plugins/importer/importgedcom.py b/gramps/plugins/importer/importgedcom.py index 5f095674a..34a1d4876 100644 --- a/gramps/plugins/importer/importgedcom.py +++ b/gramps/plugins/importer/importgedcom.py @@ -131,7 +131,9 @@ def importData(database, filename, user): try: read_only = database.readonly database.readonly = False + database.prepare_import() gedparse.parse_gedcom_file(False) + database.commit_import() database.readonly = read_only ifile.close() except IOError as msg: diff --git a/gramps/plugins/importer/importgeneweb.py b/gramps/plugins/importer/importgeneweb.py index 1ad57fc16..5147ebc57 100644 --- a/gramps/plugins/importer/importgeneweb.py +++ b/gramps/plugins/importer/importgeneweb.py @@ -87,7 +87,9 @@ def importData(database, filename, user): return try: + database.prepare_import() status = g.parse_geneweb_file() + database.commit_import() except IOError as msg: errmsg = _("%s could not be opened\n") % filename user.notify_error(errmsg,str(msg)) diff --git a/gramps/plugins/importer/importgpkg.py b/gramps/plugins/importer/importgpkg.py index 3c7f1b4c7..2a164b09d 100644 --- a/gramps/plugins/importer/importgpkg.py +++ b/gramps/plugins/importer/importgpkg.py @@ -93,7 +93,9 @@ def impData(database, name, user): imp_db_name = os.path.join(tmpdir_path, XMLFILE) importer = importData + database.prepare_import() info = importer(database, imp_db_name, user) + database.commit_import() newmediapath = database.get_mediapath() #import of gpkg should not change media path as all media has new paths! diff --git a/gramps/plugins/importer/importprogen.py b/gramps/plugins/importer/importprogen.py index 16b72eeea..3ad119660 100644 --- a/gramps/plugins/importer/importprogen.py +++ b/gramps/plugins/importer/importprogen.py @@ -75,7 +75,9 @@ def _importData(database, filename, user): return try: + database.prepare_import() status = g.parse_progen_file() + database.commit_import() except ProgenError as msg: user.notify_error(_("Pro-Gen data error"), str(msg)) return diff --git a/gramps/plugins/importer/importvcard.py b/gramps/plugins/importer/importvcard.py index 9495afb5f..e9f42d44b 100644 --- a/gramps/plugins/importer/importvcard.py +++ b/gramps/plugins/importer/importvcard.py @@ -63,8 +63,10 @@ def importData(database, filename, user): """Function called by Gramps to import data on persons in VCard format.""" parser = VCardParser(database) try: + database.prepare_import() with OpenFileOrStdin(filename) as filehandle: parser.parse(filehandle) + database.commit_import() except EnvironmentError as msg: user.notify_error(_("%s could not be opened\n") % filename, str(msg)) return diff --git a/gramps/plugins/importer/importxml.py b/gramps/plugins/importer/importxml.py index 3cbea0785..acee74f69 100644 --- a/gramps/plugins/importer/importxml.py +++ b/gramps/plugins/importer/importxml.py @@ -122,6 +122,7 @@ def importData(database, filename, user): line_cnt = 0 person_cnt = 0 + database.prepare_import() with ImportOpenFileContextManager(filename, user) as xml_file: if xml_file is None: return @@ -162,6 +163,7 @@ def importData(database, filename, user): "valid Gramps database.")) return + database.commit_import() database.readonly = read_only return info diff --git a/gramps/webapp/reports.py b/gramps/webapp/reports.py index c0c7f480e..35cc66356 100644 --- a/gramps/webapp/reports.py +++ b/gramps/webapp/reports.py @@ -85,9 +85,9 @@ def import_file(db, filename, user): print("ERROR:", name, exception) return False import_function = getattr(mod, pdata.import_function) - db.prepare_import() + #db.prepare_import() retval = import_function(db, filename, user) - db.commit_import() + #db.commit_import() return retval return False