Protection from null objects

svn: r15504
This commit is contained in:
Doug Blank 2010-05-30 11:35:45 +00:00
parent 27d27113ce
commit 41a4ff748d

View File

@ -126,8 +126,13 @@ class ReferencedBySelectionProxyDb(ProxyDbBase):
Follow the person object and find all of the primary objects Follow the person object and find all of the primary objects
that it references. that it references.
""" """
# A non-person:
if person is None:
return
# A person we have seen before:
if person.handle in self.referenced["Person"]: if person.handle in self.referenced["Person"]:
return return
# A person that we should not add:
if (self.restricted_to["Person"] and if (self.restricted_to["Person"] and
person.handle not in self.restricted_to["Person"]): person.handle not in self.restricted_to["Person"]):
return return
@ -177,7 +182,7 @@ class ReferencedBySelectionProxyDb(ProxyDbBase):
Follow the family object and find all of the primary objects Follow the family object and find all of the primary objects
that it references. that it references.
""" """
if family.handle in self.referenced["Family"]: if family is None or family.handle in self.referenced["Family"]:
return return
self.referenced["Family"].add(family.handle) self.referenced["Family"].add(family.handle)
@ -207,7 +212,7 @@ class ReferencedBySelectionProxyDb(ProxyDbBase):
Follow the event object and find all of the primary objects Follow the event object and find all of the primary objects
that it references. that it references.
""" """
if event.handle in self.referenced["Event"]: if event is None or event.handle in self.referenced["Event"]:
return return
self.referenced["Event"].add(event.handle) self.referenced["Event"].add(event.handle)
self.process_source_ref_list(event) self.process_source_ref_list(event)
@ -225,7 +230,7 @@ class ReferencedBySelectionProxyDb(ProxyDbBase):
Follow the place object and find all of the primary objects Follow the place object and find all of the primary objects
that it references. that it references.
""" """
if place.handle in self.referenced["Place"]: if place is None or place.handle in self.referenced["Place"]:
return return
self.referenced["Place"].add(place.handle) self.referenced["Place"].add(place.handle)
self.process_source_ref_list(place) self.process_source_ref_list(place)
@ -238,7 +243,7 @@ class ReferencedBySelectionProxyDb(ProxyDbBase):
Follow the source object and find all of the primary objects Follow the source object and find all of the primary objects
that it references. that it references.
""" """
if source.handle in self.referenced["Source"]: if source is None or source.handle in self.referenced["Source"]:
return return
self.referenced["Source"].add(source.handle) self.referenced["Source"].add(source.handle)
for repo_ref in source.get_reporef_list(): for repo_ref in source.get_reporef_list():
@ -256,7 +261,7 @@ class ReferencedBySelectionProxyDb(ProxyDbBase):
Follow the repository object and find all of the primary objects Follow the repository object and find all of the primary objects
that it references. that it references.
""" """
if repository.handle in self.referenced["Repository"]: if repository is None or repository.handle in self.referenced["Repository"]:
return return
self.referenced["Repository"].add(repository.handle) self.referenced["Repository"].add(repository.handle)
self.process_notes(repository) self.process_notes(repository)
@ -268,7 +273,7 @@ class ReferencedBySelectionProxyDb(ProxyDbBase):
Follow the media object and find all of the primary objects Follow the media object and find all of the primary objects
that it references. that it references.
""" """
if media.handle in self.referenced["MediaObject"]: if media is None or media.handle in self.referenced["MediaObject"]:
return return
self.referenced["MediaObject"].add(media.handle) self.referenced["MediaObject"].add(media.handle)
self.process_source_ref_list(media) self.process_source_ref_list(media)