* src/GrampsDb/_DbUtils.py: Use normal addition: this updates
reference_map properly. svn: r7297
This commit is contained in:
parent
0948f599a4
commit
04bbebf702
@ -1,4 +1,6 @@
|
|||||||
2006-09-01 Alex Roitman <shura@gramps-project.org>
|
2006-09-01 Alex Roitman <shura@gramps-project.org>
|
||||||
|
* src/GrampsDb/_DbUtils.py: Use normal addition: this updates
|
||||||
|
reference_map properly.
|
||||||
* src/plugins/StatisticsChart.py: Remove cause.
|
* src/plugins/StatisticsChart.py: Remove cause.
|
||||||
* src/GrampsDb/_WriteXML.py (write_object): Escape path of the files;
|
* src/GrampsDb/_WriteXML.py (write_object): Escape path of the files;
|
||||||
(fix): remove control characters.
|
(fix): remove control characters.
|
||||||
|
@ -173,54 +173,42 @@ def db_copy(from_db,to_db,callback):
|
|||||||
|
|
||||||
tables = {
|
tables = {
|
||||||
'Person': {'cursor_func': from_db.get_person_cursor,
|
'Person': {'cursor_func': from_db.get_person_cursor,
|
||||||
'table': to_db.person_map,
|
'add_func' : to_db.add_person,
|
||||||
'sec_table' : to_db.id_trans },
|
},
|
||||||
'Family': {'cursor_func': from_db.get_family_cursor,
|
'Family': {'cursor_func': from_db.get_family_cursor,
|
||||||
'table': to_db.family_map,
|
'add_func' : to_db.add_family,
|
||||||
'sec_table' : to_db.fid_trans },
|
},
|
||||||
'Event': {'cursor_func': from_db.get_event_cursor,
|
'Event': {'cursor_func': from_db.get_event_cursor,
|
||||||
'table': to_db.event_map,
|
'add_func' : to_db.add_event,
|
||||||
'sec_table' : to_db.eid_trans },
|
},
|
||||||
'Place': {'cursor_func': from_db.get_place_cursor,
|
'Place': {'cursor_func': from_db.get_place_cursor,
|
||||||
'table': to_db.place_map,
|
'add_func' : to_db.add_place,
|
||||||
'sec_table' : to_db.pid_trans },
|
},
|
||||||
'Source': {'cursor_func': from_db.get_source_cursor,
|
'Source': {'cursor_func': from_db.get_source_cursor,
|
||||||
'table': to_db.source_map,
|
'add_func' : to_db.add_source,
|
||||||
'sec_table' : to_db.sid_trans },
|
},
|
||||||
'MediaObject': {'cursor_func': from_db.get_media_cursor,
|
'MediaObject': {'cursor_func': from_db.get_media_cursor,
|
||||||
'table': to_db.media_map,
|
'add_func' : to_db.add_object,
|
||||||
'sec_table' : to_db.oid_trans },
|
},
|
||||||
'Repository': {'cursor_func': from_db.get_repository_cursor,
|
'Repository': {'cursor_func': from_db.get_repository_cursor,
|
||||||
'table': to_db.repository_map,
|
'add_func' : to_db.add_repository,
|
||||||
'sec_table' : to_db.rid_trans },
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if to_db.__class__.__name__ == 'GrampsBSDDB':
|
|
||||||
if to_db.UseTXN:
|
|
||||||
add_data = add_data_txn
|
|
||||||
else:
|
|
||||||
add_data = add_data_notxn
|
|
||||||
update_secondary = update_secondary_empty
|
|
||||||
else:
|
|
||||||
add_data = add_data_dict
|
|
||||||
# For InMem databases, the secondary indices need to be
|
|
||||||
# created as we copy objects
|
|
||||||
update_secondary = update_secondary_inmem
|
|
||||||
|
|
||||||
# Start batch transaction to use async TXN and other tricks
|
# Start batch transaction to use async TXN and other tricks
|
||||||
trans = to_db.transaction_begin("",batch=True)
|
trans = to_db.transaction_begin("",batch=True)
|
||||||
|
|
||||||
for table_name in tables.keys():
|
for table_name in tables.keys():
|
||||||
cursor_func = tables[table_name]['cursor_func']
|
cursor_func = tables[table_name]['cursor_func']
|
||||||
table = tables[table_name]['table']
|
add_func = tables[table_name]['add_func']
|
||||||
sec_table = tables[table_name]['sec_table']
|
|
||||||
|
|
||||||
cursor = cursor_func()
|
cursor = cursor_func()
|
||||||
item = cursor.first()
|
item = cursor.first()
|
||||||
while item:
|
while item:
|
||||||
(handle,data) = item
|
(handle,data) = item
|
||||||
add_data(to_db,table,handle,data)
|
exec('obj = RelLib.%s()' % table_name)
|
||||||
update_secondary(sec_table,handle,data)
|
obj.unserialize(data)
|
||||||
|
add_func(obj,trans)
|
||||||
item = cursor.next()
|
item = cursor.next()
|
||||||
uc.update()
|
uc.update()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
@ -241,41 +229,6 @@ def db_copy(from_db,to_db,callback):
|
|||||||
# Copy name formats
|
# Copy name formats
|
||||||
to_db.name_formats = from_db.name_formats
|
to_db.name_formats = from_db.name_formats
|
||||||
|
|
||||||
# Copy gender stats
|
|
||||||
to_db.genderStats = from_db.genderStats
|
|
||||||
|
|
||||||
# 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()
|
|
||||||
table.put(handle,data,txn=the_txn)
|
|
||||||
the_txn.commit()
|
|
||||||
|
|
||||||
def add_data_notxn(db,table,handle,data):
|
|
||||||
table.put(handle,data)
|
|
||||||
|
|
||||||
def add_data_dict(db,table,handle,data):
|
|
||||||
table[handle] = data
|
|
||||||
|
|
||||||
def update_secondary_empty(sec_table,handle,data):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def update_secondary_inmem(sec_table,handle,data):
|
|
||||||
sec_table[str(data[1])] = str(handle)
|
|
||||||
|
|
||||||
def set_birth_death_index(db, person):
|
def set_birth_death_index(db, person):
|
||||||
birth_ref_index = -1
|
birth_ref_index = -1
|
||||||
death_ref_index = -1
|
death_ref_index = -1
|
||||||
|
Loading…
Reference in New Issue
Block a user