* src/GrampsDb/_GrampsDbBase.py (remove_person,_do_remove_object):

Properly delete objects;
	(get_del_func): Add method to find deleting function for an object.
	* src/plugins/Check.py (cleanup_empty_families): Report gramps id.


svn: r7292
This commit is contained in:
Alex Roitman 2006-08-30 05:10:50 +00:00
parent 731665985a
commit f758557ca3
3 changed files with 38 additions and 13 deletions

View File

@ -1,4 +1,8 @@
2006-08-29 Alex Roitman <shura@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py (remove_person,_do_remove_object):
Properly delete objects;
(get_del_func): Add method to find deleting function for an object.
* src/plugins/Check.py (cleanup_empty_families): Report gramps id.
* src/RelLib/_SourceRef.py (SourceRef.__init__): Pass source.
* src/RelLib/_ChildRef.py (ChildRef.__init__): Pass source.
* src/RelLib/_EventRef.py (EventRef.__init__): Pass source.

View File

@ -1700,21 +1700,41 @@ class GrampsDbBase(GrampsDBCallback):
method must be overridden in the derived class.
"""
if self.readonly or not handle:
return
self._delete_primary_from_reference_map(handle, transaction)
if not self.readonly:
person = self.get_person_from_handle(handle)
self.genderStats.uncount_person (person)
if not transaction.batch:
transaction.add(PERSON_KEY, handle, person.serialize(), None)
person = self.get_person_from_handle(handle)
self.genderStats.uncount_person (person)
if transaction.batch:
self._del_person(handle)
else:
transaction.add(PERSON_KEY, handle, person.serialize(), None)
transaction.person_del.append(str(handle))
def get_del_func(self,key):
key2del = {
PERSON_KEY: self._del_person,
FAMILY_KEY: self._del_family,
SOURCE_KEY: self._del_source,
EVENT_KEY: self._del_event,
MEDIA_KEY: self._del_media,
PLACE_KEY: self._del_place,
REPOSITORY_KEY: self._del_repository,
}
return key2del[key]
def _do_remove_object(self, handle, trans, dmap, key, del_list):
if self.readonly or not handle:
return
handle = str(handle)
self._delete_primary_from_reference_map(handle, trans)
if not self.readonly:
handle = str(handle)
if not trans.batch:
old_data = dmap.get(handle)
trans.add(key, handle, old_data, None)
if trans.batch:
del_func = self.get_del_func(key)
del_func(handle)
else:
old_data = dmap.get(handle)
trans.add(key, handle, old_data, None)
del_list.append(handle)
def remove_source(self, handle, transaction):

View File

@ -510,11 +510,12 @@ class CheckIntegrity:
self.progress.step()
family = self.db.get_family_from_handle(family_handle)
family_id = family.get_gramps_id()
father_handle = family.get_father_handle()
mother_handle = family.get_mother_handle()
if not father_handle and not mother_handle:
self.empty_family.append(family_handle)
self.empty_family.append(family_id)
self.delete_empty_family(family_handle)
continue
elif not father_handle and len(family.get_child_ref_list()) == 0:
@ -522,14 +523,14 @@ class CheckIntegrity:
person.remove_family_handle(family_handle)
self.db.commit_person(person,self.trans)
self.db.remove_family(family_handle,self.trans)
self.empty_family.append(family_handle)
self.empty_family.append(family_id)
continue
elif not mother_handle and len(family.get_child_ref_list()) == 0:
person = self.db.get_person_from_handle(father_handle)
person.remove_family_handle(family_handle)
self.db.commit_person(person,self.trans)
self.db.remove_family(family_handle,self.trans)
self.empty_family.append(family_handle)
self.empty_family.append(family_id)
continue
def delete_empty_family(self,family_handle):