diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index c03947d4a..16fa13d19 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,6 @@ +2006-05-19 Alex Roitman + * src/GrampsDb/_DbUtils.py (db_copy): Copy custom types. + 2006-05-19 Martin Hawlisch * src/DataViews/_MapView.py (WMSMapTile): Start of map download inside an idle handler. diff --git a/gramps2/src/GrampsDb/_DbUtils.py b/gramps2/src/GrampsDb/_DbUtils.py index a075faf5e..7cdd7e50e 100644 --- a/gramps2/src/GrampsDb/_DbUtils.py +++ b/gramps2/src/GrampsDb/_DbUtils.py @@ -160,6 +160,14 @@ def get_total(db): place_len + source_len + obj_len + repo_len def db_copy(from_db,to_db,callback): + """ + Copy all data in from_db into to_db. + + Both databases must be loaded. + It is assumed that to_db is an empty database, + so no care is taken to prevent handle collision or merge data. + """ + uc = UpdateCallback(callback) uc.set_total(get_total(from_db)) @@ -233,8 +241,20 @@ def db_copy(from_db,to_db,callback): # Copy gender stats to_db.genderStats = from_db.genderStats - # FIXME: need to also copy event/attr names - # TODO: need to also copy event/attr names + # Copy custom types + to_db.family_event_names = from_db.family_event_names + to_db.individual_event_names = from_db.individual_event_names + to_db.family_attributes = from_db.family_attributes + to_db.individual_attributes = from_db.individual_attributes + to_db.marker_names = from_db.marker_names + to_db.child_ref_types = from_db.child_ref_types + to_db.family_rel_types = from_db.family_rel_types + to_db.event_role_names = from_db.event_role_names + to_db.name_types = from_db.name_types + to_db.repository_types = from_db.repository_types + to_db.source_media_types = from_db.source_media_types + to_db.url_types = from_db.url_types + to_db.media_attributes = from_db.media_attributes def add_data_txn(db,table,handle,data): the_txn = db.env.txn_begin() diff --git a/gramps2/src/GrampsDb/_GrampsDbBase.py b/gramps2/src/GrampsDb/_GrampsDbBase.py index d38410157..52384a529 100644 --- a/gramps2/src/GrampsDb/_GrampsDbBase.py +++ b/gramps2/src/GrampsDb/_GrampsDbBase.py @@ -914,32 +914,36 @@ class GrampsDbBase(GrampsDBCallback): assert False, "Needs to be overridden in the derived class" def get_place_from_gramps_id(self, val): - """finds a Place in the database from the passed gramps' ID. - If no such Place exists, a new Person is added to the database. + """ + Finds a Place in the database from the passed gramps' ID. + If no such Place exists, None is returned. Needs to be overridden by the derrived class. """ assert False, "Needs to be overridden in the derived class" def get_source_from_gramps_id(self, val): - """finds a Source in the database from the passed gramps' ID. - If no such Source exists, a new Person is added to the database. + """ + Finds a Source in the database from the passed gramps' ID. + If no such Source exists, None is returned. Needs to be overridden by the derrived class. """ assert False, "Needs to be overridden in the derived class" def get_object_from_gramps_id(self, val): - """finds a MediaObject in the database from the passed gramps' ID. - If no such MediaObject exists, a new Person is added to the database. + """ + Finds a MediaObject in the database from the passed gramps' ID. + If no such MediaObject exists, None is returned. Needs to be overridden by the derrived class. """ assert False, "Needs to be overridden in the derived class" def get_repository_from_gramps_id(self, val): - """finds a Repository in the database from the passed gramps' ID. - If no such Repository exists, a new Repository is added to the database. + """ + Finds a Repository in the database from the passed gramps' ID. + If no such MediaObject exists, None is returned. Needs to be overridden by the derrived class. """