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

svn: r21796
This commit is contained in:
Tim G L Lyons 2013-03-28 18:28:44 +00:00
parent 645262992d
commit 6fe6455251
2 changed files with 56 additions and 36 deletions

View File

@ -139,20 +139,21 @@ class FilterProxyDb(ProxyDbBase):
If no such Source exists, None is returned.
"""
source = self.db.get_source_from_handle(handle)
# Filter notes out
self.sanitize_notebase(source)
media_ref_list = source.get_media_list()
for media_ref in media_ref_list:
self.sanitize_notebase(media_ref)
attributes = media_ref.get_attribute_list()
for attribute in attributes:
self.sanitize_notebase(attribute)
if source:
# Filter notes out
self.sanitize_notebase(source)
repo_ref_list = source.get_reporef_list()
for repo_ref in repo_ref_list:
self.sanitize_notebase(repo_ref)
media_ref_list = source.get_media_list()
for media_ref in media_ref_list:
self.sanitize_notebase(media_ref)
attributes = media_ref.get_attribute_list()
for attribute in attributes:
self.sanitize_notebase(attribute)
repo_ref_list = source.get_reporef_list()
for repo_ref in repo_ref_list:
self.sanitize_notebase(repo_ref)
return source
@ -163,7 +164,6 @@ class FilterProxyDb(ProxyDbBase):
"""
citation = self.db.get_citation_from_handle(handle)
# Filter notes out
self.sanitize_notebase(citation)
return citation
@ -173,12 +173,14 @@ class FilterProxyDb(ProxyDbBase):
If no such Object exists, None is returned.
"""
media = self.db.get_object_from_handle(handle)
# Filter notes out
self.sanitize_notebase(media)
attributes = media.get_attribute_list()
for attr in attributes:
self.sanitize_notebase(attr)
if media:
# Filter notes out
self.sanitize_notebase(media)
attributes = media.get_attribute_list()
for attr in attributes:
self.sanitize_notebase(attr)
return media
@ -188,15 +190,17 @@ class FilterProxyDb(ProxyDbBase):
If no such Place exists, None is returned.
"""
place = self.db.get_place_from_handle(handle)
# Filter notes out
self.sanitize_notebase(place)
media_ref_list = place.get_media_list()
for media_ref in media_ref_list:
self.sanitize_notebase(media_ref)
attributes = media_ref.get_attribute_list()
for attribute in attributes:
self.sanitize_notebase(attribute)
if place:
# Filter notes out
self.sanitize_notebase(place)
media_ref_list = place.get_media_list()
for media_ref in media_ref_list:
self.sanitize_notebase(media_ref)
attributes = media_ref.get_attribute_list()
for attribute in attributes:
self.sanitize_notebase(attribute)
return place
@ -297,6 +301,8 @@ class FilterProxyDb(ProxyDbBase):
person = self.db.get_person_from_gramps_id(val)
if person:
return self.get_person_from_handle(person.get_handle())
else:
return None
def get_family_from_gramps_id(self, val):
"""
@ -306,6 +312,8 @@ class FilterProxyDb(ProxyDbBase):
family = self.db.get_family_from_gramps_id(val)
if family:
return self.get_family_from_handle(family.get_handle())
else:
return None
def get_event_from_gramps_id(self, val):
"""
@ -315,6 +323,8 @@ class FilterProxyDb(ProxyDbBase):
event = self.db.get_event_from_gramps_id(val)
if event:
return self.get_event_from_handle(event.get_handle())
else:
return None
def get_place_from_gramps_id(self, val):
"""
@ -324,6 +334,8 @@ class FilterProxyDb(ProxyDbBase):
place = self.db.get_place_from_gramps_id(val)
if place:
return self.get_place_from_handle(place.get_handle())
else:
return None
def get_source_from_gramps_id(self, val):
"""
@ -333,6 +345,8 @@ class FilterProxyDb(ProxyDbBase):
source = self.db.get_source_from_gramps_id(val)
if source:
return self.get_source_from_handle(source.get_handle())
else:
return None
def get_citation_from_gramps_id(self, val):
"""
@ -342,6 +356,8 @@ class FilterProxyDb(ProxyDbBase):
citation = self.db.get_citation_from_gramps_id(val)
if citation:
return self.get_citation_from_handle(citation.get_handle())
else:
return None
def get_object_from_gramps_id(self, val):
"""
@ -351,6 +367,8 @@ class FilterProxyDb(ProxyDbBase):
media = self.db.get_object_from_gramps_id(val)
if media:
return self.get_object_from_handle(media.get_handle())
else:
return None
def get_repository_from_gramps_id(self, val):
"""
@ -360,6 +378,8 @@ class FilterProxyDb(ProxyDbBase):
repository = self.db.get_repository_from_gramps_id(val)
if repository:
return self.get_repository_from_handle(repository.get_handle())
else:
return None
def get_note_from_gramps_id(self, val):
"""
@ -369,6 +389,8 @@ class FilterProxyDb(ProxyDbBase):
note = self.db.get_note_from_gramps_id(val)
if note:
return self.get_note_from_handle(note.get_handle())
else:
return None
def get_person_handles(self, sort_handles=False):
"""

View File

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