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. If no such Source exists, None is returned.
""" """
source = self.db.get_source_from_handle(handle) source = self.db.get_source_from_handle(handle)
# Filter notes out
self.sanitize_notebase(source) if source:
# Filter notes out
media_ref_list = source.get_media_list() self.sanitize_notebase(source)
for media_ref in media_ref_list:
self.sanitize_notebase(media_ref) media_ref_list = source.get_media_list()
attributes = media_ref.get_attribute_list() for media_ref in media_ref_list:
for attribute in attributes: self.sanitize_notebase(media_ref)
self.sanitize_notebase(attribute) attributes = media_ref.get_attribute_list()
for attribute in attributes:
repo_ref_list = source.get_reporef_list() self.sanitize_notebase(attribute)
for repo_ref in repo_ref_list:
self.sanitize_notebase(repo_ref) repo_ref_list = source.get_reporef_list()
for repo_ref in repo_ref_list:
self.sanitize_notebase(repo_ref)
return source return source
@ -163,7 +164,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
@ -173,12 +173,14 @@ 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)
# Filter notes out
self.sanitize_notebase(media) if media:
# Filter notes out
attributes = media.get_attribute_list() self.sanitize_notebase(media)
for attr in attributes:
self.sanitize_notebase(attr) attributes = media.get_attribute_list()
for attr in attributes:
self.sanitize_notebase(attr)
return media return media
@ -188,15 +190,17 @@ 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)
# Filter notes out
self.sanitize_notebase(place)
media_ref_list = place.get_media_list() if place:
for media_ref in media_ref_list: # Filter notes out
self.sanitize_notebase(media_ref) self.sanitize_notebase(place)
attributes = media_ref.get_attribute_list()
for attribute in attributes: media_ref_list = place.get_media_list()
self.sanitize_notebase(attribute) 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 return place
@ -297,6 +301,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):
""" """
@ -306,6 +312,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):
""" """
@ -315,6 +323,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):
""" """
@ -324,6 +334,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):
""" """
@ -333,6 +345,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):
""" """
@ -342,6 +356,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):
""" """
@ -351,6 +367,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):
""" """
@ -360,6 +378,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):
""" """
@ -369,6 +389,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,9 +399,10 @@ 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()
place = self.db.get_place_from_handle(place_handle) if place_handle:
if place: place = self.db.get_place_from_handle(place_handle)
self.process_place(place) if place:
self.process_place(place)
self.process_citation_ref_list(lds_ord) self.process_citation_ref_list(lds_ord)
self.process_notes(lds_ord) self.process_notes(lds_ord)