Added remove_func to _tables; added remove_from_database(item)

This commit is contained in:
Doug Blank 2013-12-23 13:56:25 -05:00
parent 5586474ec5
commit 27453a7587
5 changed files with 56 additions and 0 deletions

View File

@ -119,6 +119,7 @@ class DictionaryDb(DbWriteBase, DbReadBase):
"handles_func": self.get_person_handles,
"add_func": self.add_person,
"commit_func": self.commit_person,
"remove_func": self.remove_person,
})
self._tables['Family'].update(
{
@ -129,6 +130,7 @@ class DictionaryDb(DbWriteBase, DbReadBase):
"handles_func": self.get_family_handles,
"add_func": self.add_family,
"commit_func": self.commit_family,
"remove_func": self.remove_family,
})
self._tables['Source'].update(
{
@ -139,6 +141,7 @@ class DictionaryDb(DbWriteBase, DbReadBase):
"handles_func": self.get_source_handles,
"add_func": self.add_source,
"commit_func": self.commit_source,
"remove_func": self.remove_source,
})
self._tables['Citation'].update(
{
@ -149,6 +152,7 @@ class DictionaryDb(DbWriteBase, DbReadBase):
"handles_func": self.get_citation_handles,
"add_func": self.add_citation,
"commit_func": self.commit_citation,
"remove_func": self.remove_citation,
})
self._tables['Event'].update(
{
@ -159,6 +163,7 @@ class DictionaryDb(DbWriteBase, DbReadBase):
"handles_func": self.get_event_handles,
"add_func": self.add_event,
"commit_func": self.commit_event,
"remove_func": self.remove_event,
})
self._tables['Media'].update(
{
@ -169,6 +174,7 @@ class DictionaryDb(DbWriteBase, DbReadBase):
"handles_func": self.get_media_object_handles,
"add_func": self.add_object,
"commit_func": self.commit_media_object,
"remove_func": self.remove_object,
})
self._tables['Place'].update(
{
@ -179,6 +185,7 @@ class DictionaryDb(DbWriteBase, DbReadBase):
"handles_func": self.get_place_handles,
"add_func": self.add_place,
"commit_func": self.commit_place,
"remove_func": self.remove_place,
})
self._tables['Repository'].update(
{
@ -189,6 +196,7 @@ class DictionaryDb(DbWriteBase, DbReadBase):
"handles_func": self.get_repository_handles,
"add_func": self.add_repository,
"commit_func": self.commit_repository,
"remove_func": self.remove_repository,
})
self._tables['Note'].update(
{
@ -199,6 +207,7 @@ class DictionaryDb(DbWriteBase, DbReadBase):
"handles_func": self.get_note_handles,
"add_func": self.add_note,
"commit_func": self.commit_note,
"remove_func": self.remove_note,
})
self._tables['Tag'].update(
{
@ -209,6 +218,7 @@ class DictionaryDb(DbWriteBase, DbReadBase):
"handles_func": self.get_tag_handles,
"add_func": self.add_tag,
"commit_func": self.commit_tag,
"remove_func": self.remove_tag,
})
# skip GEDCOM cross-ref check for now:
self.set_feature("skip-check-xref", True)

View File

@ -294,6 +294,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
"handles_func": self.get_person_handles,
"add_func": self.add_person,
"commit_func": self.commit_person,
"remove_func": self.remove_person,
})
self._tables['Family'].update(
{
@ -304,6 +305,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
"handles_func": self.get_family_handles,
"add_func": self.add_family,
"commit_func": self.commit_family,
"remove_func": self.remove_family,
})
self._tables['Source'].update(
{
@ -314,6 +316,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
"handles_func": self.get_source_handles,
"add_func": self.add_source,
"commit_func": self.commit_source,
"remove_func": self.remove_source,
})
self._tables['Citation'].update(
{
@ -324,6 +327,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
"handles_func": self.get_citation_handles,
"add_func": self.add_citation,
"commit_func": self.commit_citation,
"remove_func": self.remove_citation,
})
self._tables['Event'].update(
{
@ -334,6 +338,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
"handles_func": self.get_event_handles,
"add_func": self.add_event,
"commit_func": self.commit_event,
"remove_func": self.remove_event,
})
self._tables['Media'].update(
{
@ -344,6 +349,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
"handles_func": self.get_media_object_handles,
"add_func": self.add_object,
"commit_func": self.commit_media_object,
"remove_func": self.remove_object,
})
self._tables['Place'].update(
{
@ -354,6 +360,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
"handles_func": self.get_place_handles,
"add_func": self.add_place,
"commit_func": self.commit_place,
"remove_func": self.remove_place,
})
self._tables['Repository'].update(
{
@ -364,6 +371,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
"handles_func": self.get_repository_handles,
"add_func": self.add_repository,
"commit_func": self.commit_repository,
"remove_func": self.remove_repository,
})
self._tables['Note'].update(
{
@ -374,6 +382,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
"handles_func": self.get_note_handles,
"add_func": self.add_note,
"commit_func": self.commit_note,
"remove_func": self.remove_note,
})
self._tables['Tag'].update(
{
@ -384,6 +393,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
"handles_func": self.get_tag_handles,
"add_func": self.add_tag,
"commit_func": self.commit_tag,
"remove_func": self.remove_tag,
})
self.secondary_connected = False
@ -2421,6 +2431,12 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
"""
return DbTxn
def remove_from_database(self, item, transaction):
"""
Remove the item from the database.
"""
self._tables[item.__class__.__name__]["remove_func"](item.handle, transaction)
def _mkname(path, name):
return os.path.join(path, name + DBEXT)

View File

@ -98,6 +98,7 @@ class LivingProxyDb(ProxyDbBase):
"class_func": Person,
"cursor_func": self.get_person_cursor,
"handles_func": self.get_person_handles,
"remove_func": self.remove_person,
})
self._tables['Family'].update(
{
@ -106,6 +107,7 @@ class LivingProxyDb(ProxyDbBase):
"class_func": Family,
"cursor_func": self.get_family_cursor,
"handles_func": self.get_family_handles,
"remove_func": self.remove_family,
})
self._tables['Source'].update(
{
@ -114,6 +116,7 @@ class LivingProxyDb(ProxyDbBase):
"class_func": Source,
"cursor_func": self.get_source_cursor,
"handles_func": self.get_source_handles,
"remove_func": self.remove_source,
})
self._tables['Citation'].update(
{
@ -122,6 +125,7 @@ class LivingProxyDb(ProxyDbBase):
"class_func": Citation,
"cursor_func": self.get_citation_cursor,
"handles_func": self.get_citation_handles,
"remove_func": self.remove_citation,
})
self._tables['Event'].update(
{
@ -130,6 +134,7 @@ class LivingProxyDb(ProxyDbBase):
"class_func": Event,
"cursor_func": self.get_event_cursor,
"handles_func": self.get_event_handles,
"remove_func": self.remove_event,
})
self._tables['Media'].update(
{
@ -138,6 +143,7 @@ class LivingProxyDb(ProxyDbBase):
"class_func": MediaObject,
"cursor_func": self.get_media_cursor,
"handles_func": self.get_media_object_handles,
"remove_func": self.remove_object,
})
self._tables['Place'].update(
{
@ -146,6 +152,7 @@ class LivingProxyDb(ProxyDbBase):
"class_func": Place,
"cursor_func": self.get_place_cursor,
"handles_func": self.get_place_handles,
"remove_func": self.remove_place,
})
self._tables['Repository'].update(
{
@ -154,6 +161,7 @@ class LivingProxyDb(ProxyDbBase):
"class_func": Repository,
"cursor_func": self.get_repository_cursor,
"handles_func": self.get_repository_handles,
"remove_func": self.remove_repository,
})
self._tables['Note'].update(
{
@ -162,6 +170,7 @@ class LivingProxyDb(ProxyDbBase):
"class_func": Note,
"cursor_func": self.get_note_cursor,
"handles_func": self.get_note_handles,
"remove_func": self.remove_note,
})
self._tables['Tag'].update(
{
@ -170,6 +179,7 @@ class LivingProxyDb(ProxyDbBase):
"class_func": Tag,
"cursor_func": self.get_tag_cursor,
"handles_func": self.get_tag_handles,
"remove_func": self.remove_tag,
})
def get_person_from_handle(self, handle):

View File

@ -65,6 +65,7 @@ class PrivateProxyDb(ProxyDbBase):
"class_func": Person,
"cursor_func": self.get_person_cursor,
"handles_func": self.get_person_handles,
"remove_func": self.remove_person,
})
self._tables['Family'].update(
{
@ -73,6 +74,7 @@ class PrivateProxyDb(ProxyDbBase):
"class_func": Family,
"cursor_func": self.get_family_cursor,
"handles_func": self.get_family_handles,
"remove_func": self.remove_family,
})
self._tables['Source'].update(
{
@ -81,6 +83,7 @@ class PrivateProxyDb(ProxyDbBase):
"class_func": Source,
"cursor_func": self.get_source_cursor,
"handles_func": self.get_source_handles,
"remove_func": self.remove_source,
})
self._tables['Citation'].update(
{
@ -89,6 +92,7 @@ class PrivateProxyDb(ProxyDbBase):
"class_func": Citation,
"cursor_func": self.get_citation_cursor,
"handles_func": self.get_citation_handles,
"remove_func": self.remove_citation,
})
self._tables['Event'].update(
{
@ -97,6 +101,7 @@ class PrivateProxyDb(ProxyDbBase):
"class_func": Event,
"cursor_func": self.get_event_cursor,
"handles_func": self.get_event_handles,
"remove_func": self.remove_event,
})
self._tables['Media'].update(
{
@ -105,6 +110,7 @@ class PrivateProxyDb(ProxyDbBase):
"class_func": MediaObject,
"cursor_func": self.get_media_cursor,
"handles_func": self.get_media_object_handles,
"remove_func": self.remove_object,
})
self._tables['Place'].update(
{
@ -113,6 +119,7 @@ class PrivateProxyDb(ProxyDbBase):
"class_func": Place,
"cursor_func": self.get_place_cursor,
"handles_func": self.get_place_handles,
"remove_func": self.remove_place,
})
self._tables['Repository'].update(
{
@ -121,6 +128,7 @@ class PrivateProxyDb(ProxyDbBase):
"class_func": Repository,
"cursor_func": self.get_repository_cursor,
"handles_func": self.get_repository_handles,
"remove_func": self.remove_repository,
})
self._tables['Note'].update(
{
@ -129,6 +137,7 @@ class PrivateProxyDb(ProxyDbBase):
"class_func": Note,
"cursor_func": self.get_note_cursor,
"handles_func": self.get_note_handles,
"remove_func": self.remove_note,
})
self._tables['Tag'].update(
{
@ -137,6 +146,7 @@ class PrivateProxyDb(ProxyDbBase):
"class_func": Tag,
"cursor_func": self.get_tag_cursor,
"handles_func": self.get_tag_handles,
"remove_func": self.remove_tag,
})
def get_person_from_handle(self, handle):

View File

@ -90,6 +90,7 @@ class ReferencedBySelectionProxyDb(ProxyDbBase):
"class_func": Person,
"cursor_func": self.get_person_cursor,
"handles_func": self.get_person_handles,
"remove_func": self.remove_person,
})
self._tables['Family'].update(
{
@ -98,6 +99,7 @@ class ReferencedBySelectionProxyDb(ProxyDbBase):
"class_func": Family,
"cursor_func": self.get_family_cursor,
"handles_func": self.get_family_handles,
"remove_func": self.remove_family,
})
self._tables['Source'].update(
{
@ -106,6 +108,7 @@ class ReferencedBySelectionProxyDb(ProxyDbBase):
"class_func": Source,
"cursor_func": self.get_source_cursor,
"handles_func": self.get_source_handles,
"remove_func": self.remove_source,
})
self._tables['Citation'].update(
{
@ -114,6 +117,7 @@ class ReferencedBySelectionProxyDb(ProxyDbBase):
"class_func": Citation,
"cursor_func": self.get_citation_cursor,
"handles_func": self.get_citation_handles,
"remove_func": self.remove_citation,
})
self._tables['Event'].update(
{
@ -122,6 +126,7 @@ class ReferencedBySelectionProxyDb(ProxyDbBase):
"class_func": Event,
"cursor_func": self.get_event_cursor,
"handles_func": self.get_event_handles,
"remove_func": self.remove_event,
})
self._tables['Media'].update(
{
@ -130,6 +135,7 @@ class ReferencedBySelectionProxyDb(ProxyDbBase):
"class_func": MediaObject,
"cursor_func": self.get_media_cursor,
"handles_func": self.get_media_object_handles,
"remove_func": self.remove_object,
})
self._tables['Place'].update(
{
@ -138,6 +144,7 @@ class ReferencedBySelectionProxyDb(ProxyDbBase):
"class_func": Place,
"cursor_func": self.get_place_cursor,
"handles_func": self.get_place_handles,
"remove_func": self.remove_place,
})
self._tables['Repository'].update(
{
@ -146,6 +153,7 @@ class ReferencedBySelectionProxyDb(ProxyDbBase):
"class_func": Repository,
"cursor_func": self.get_repository_cursor,
"handles_func": self.get_repository_handles,
"remove_func": self.remove_repository,
})
self._tables['Note'].update(
{
@ -154,6 +162,7 @@ class ReferencedBySelectionProxyDb(ProxyDbBase):
"class_func": Note,
"cursor_func": self.get_note_cursor,
"handles_func": self.get_note_handles,
"remove_func": self.remove_note,
})
self._tables['Tag'].update(
{
@ -162,6 +171,7 @@ class ReferencedBySelectionProxyDb(ProxyDbBase):
"class_func": Tag,
"cursor_func": self.get_tag_cursor,
"handles_func": self.get_tag_handles,
"remove_func": self.remove_tag,
})
def queue_object(self, obj_type, handle, reference=True):