2006-05-19 Alex Roitman <shura@gramps-project.org>

* src/GrampsDb/_DbUtils.py (db_copy): Copy custom types.



svn: r6726
This commit is contained in:
Alex Roitman 2006-05-20 00:52:47 +00:00
parent 1175831c49
commit 2fbeb27535
3 changed files with 37 additions and 10 deletions

View File

@ -1,3 +1,6 @@
2006-05-19 Alex Roitman <shura@gramps-project.org>
* src/GrampsDb/_DbUtils.py (db_copy): Copy custom types.
2006-05-19 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/DataViews/_MapView.py (WMSMapTile): Start of map download inside
an idle handler.

View File

@ -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()

View File

@ -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.
"""