0006544: No test for checking if Place handle exists when looking at media reference via proxy

svn: r21798
This commit is contained in:
Tim G L Lyons 2013-03-28 18:29:59 +00:00
parent ba97c071ef
commit d6f621fe72
2 changed files with 56 additions and 36 deletions

View File

@ -142,6 +142,8 @@ class FilterProxyDb(ProxyDbBase):
If no such Source exists, None is returned. If no such Source exists, None is returned.
""" """
source = self.db.get_source_from_handle(handle) source = self.db.get_source_from_handle(handle)
if source:
# Filter notes out # Filter notes out
self.sanitize_notebase(source) self.sanitize_notebase(source)
@ -156,7 +158,6 @@ class FilterProxyDb(ProxyDbBase):
for repo_ref in repo_ref_list: for repo_ref in repo_ref_list:
self.sanitize_notebase(repo_ref) self.sanitize_notebase(repo_ref)
return source return source
def get_citation_from_handle(self, handle): def get_citation_from_handle(self, handle):
@ -166,7 +167,6 @@ class FilterProxyDb(ProxyDbBase):
""" """
citation = self.db.get_citation_from_handle(handle) citation = self.db.get_citation_from_handle(handle)
# Filter notes out # Filter notes out
self.sanitize_notebase(citation) self.sanitize_notebase(citation)
return citation return citation
@ -176,6 +176,8 @@ class FilterProxyDb(ProxyDbBase):
If no such Object exists, None is returned. If no such Object exists, None is returned.
""" """
media = self.db.get_object_from_handle(handle) media = self.db.get_object_from_handle(handle)
if media:
# Filter notes out # Filter notes out
self.sanitize_notebase(media) self.sanitize_notebase(media)
@ -191,6 +193,8 @@ class FilterProxyDb(ProxyDbBase):
If no such Place exists, None is returned. If no such Place exists, None is returned.
""" """
place = self.db.get_place_from_handle(handle) place = self.db.get_place_from_handle(handle)
if place:
# Filter notes out # Filter notes out
self.sanitize_notebase(place) self.sanitize_notebase(place)
@ -300,6 +304,8 @@ class FilterProxyDb(ProxyDbBase):
person = self.db.get_person_from_gramps_id(val) person = self.db.get_person_from_gramps_id(val)
if person: if person:
return self.get_person_from_handle(person.get_handle()) return self.get_person_from_handle(person.get_handle())
else:
return None
def get_family_from_gramps_id(self, val): def get_family_from_gramps_id(self, val):
""" """
@ -309,6 +315,8 @@ class FilterProxyDb(ProxyDbBase):
family = self.db.get_family_from_gramps_id(val) family = self.db.get_family_from_gramps_id(val)
if family: if family:
return self.get_family_from_handle(family.get_handle()) return self.get_family_from_handle(family.get_handle())
else:
return None
def get_event_from_gramps_id(self, val): def get_event_from_gramps_id(self, val):
""" """
@ -318,6 +326,8 @@ class FilterProxyDb(ProxyDbBase):
event = self.db.get_event_from_gramps_id(val) event = self.db.get_event_from_gramps_id(val)
if event: if event:
return self.get_event_from_handle(event.get_handle()) return self.get_event_from_handle(event.get_handle())
else:
return None
def get_place_from_gramps_id(self, val): def get_place_from_gramps_id(self, val):
""" """
@ -327,6 +337,8 @@ class FilterProxyDb(ProxyDbBase):
place = self.db.get_place_from_gramps_id(val) place = self.db.get_place_from_gramps_id(val)
if place: if place:
return self.get_place_from_handle(place.get_handle()) return self.get_place_from_handle(place.get_handle())
else:
return None
def get_source_from_gramps_id(self, val): def get_source_from_gramps_id(self, val):
""" """
@ -336,6 +348,8 @@ class FilterProxyDb(ProxyDbBase):
source = self.db.get_source_from_gramps_id(val) source = self.db.get_source_from_gramps_id(val)
if source: if source:
return self.get_source_from_handle(source.get_handle()) return self.get_source_from_handle(source.get_handle())
else:
return None
def get_citation_from_gramps_id(self, val): def get_citation_from_gramps_id(self, val):
""" """
@ -345,6 +359,8 @@ class FilterProxyDb(ProxyDbBase):
citation = self.db.get_citation_from_gramps_id(val) citation = self.db.get_citation_from_gramps_id(val)
if citation: if citation:
return self.get_citation_from_handle(citation.get_handle()) return self.get_citation_from_handle(citation.get_handle())
else:
return None
def get_object_from_gramps_id(self, val): def get_object_from_gramps_id(self, val):
""" """
@ -354,6 +370,8 @@ class FilterProxyDb(ProxyDbBase):
media = self.db.get_object_from_gramps_id(val) media = self.db.get_object_from_gramps_id(val)
if media: if media:
return self.get_object_from_handle(media.get_handle()) return self.get_object_from_handle(media.get_handle())
else:
return None
def get_repository_from_gramps_id(self, val): def get_repository_from_gramps_id(self, val):
""" """
@ -363,6 +381,8 @@ class FilterProxyDb(ProxyDbBase):
repository = self.db.get_repository_from_gramps_id(val) repository = self.db.get_repository_from_gramps_id(val)
if repository: if repository:
return self.get_repository_from_handle(repository.get_handle()) return self.get_repository_from_handle(repository.get_handle())
else:
return None
def get_note_from_gramps_id(self, val): def get_note_from_gramps_id(self, val):
""" """
@ -372,6 +392,8 @@ class FilterProxyDb(ProxyDbBase):
note = self.db.get_note_from_gramps_id(val) note = self.db.get_note_from_gramps_id(val)
if note: if note:
return self.get_note_from_handle(note.get_handle()) return self.get_note_from_handle(note.get_handle())
else:
return None
def get_person_handles(self, sort_handles=False): def get_person_handles(self, sort_handles=False):
""" """

View File

@ -232,13 +232,10 @@ class ReferencedBySelectionProxyDb(ProxyDbBase):
self.process_attributes(event) self.process_attributes(event)
place_handle = event.get_place_handle() place_handle = event.get_place_handle()
try: if place_handle:
place = self.db.get_place_from_handle(place_handle) place = self.db.get_place_from_handle(place_handle)
if place: if place:
self.process_place(place) self.process_place(place)
except AttributeError:
import logging
logging.warning('Event:%s; Handle:%s' % (event, event.handle))
def process_place(self, place): def process_place(self, place):
""" """
@ -402,6 +399,7 @@ class ReferencedBySelectionProxyDb(ProxyDbBase):
self.process_family(fam) self.process_family(fam)
place_handle = lds_ord.get_place_handle() place_handle = lds_ord.get_place_handle()
if place_handle:
place = self.db.get_place_from_handle(place_handle) place = self.db.get_place_from_handle(place_handle)
if place: if place:
self.process_place(place) self.process_place(place)