Cleaning up Utils and refactoring common functionality

svn: r13862
This commit is contained in:
Doug Blank 2009-12-20 22:21:59 +00:00
parent f4ca61c117
commit c47b494b39

View File

@ -1526,3 +1526,40 @@ class GrampsDbBase(object):
Return whethere there were bookmark changes during the session.
"""
raise NotImplementedError
def get_birth_or_fallback(self, person):
"""
"""
birth_ref = person.get_birth_ref()
if birth_ref: # regular birth found
event = self.get_event_from_handle(birth_ref.ref)
if event:
return event
# now search the event list for fallbacks
for event_ref in person.get_primary_event_ref_list():
if event_ref:
event = self.get_event_from_handle(event_ref.ref)
if (event
and event.type.is_birth_fallback()
and event_ref.role.is_primary()):
return event
return None
def get_death_or_fallback(self, person):
"""
"""
death_ref = person.get_death_ref()
if death_ref: # regular death found
event = self.get_event_from_handle(death_ref.ref)
if event:
return event
# now search the event list for fallbacks
for event_ref in person.get_primary_event_ref_list():
if event_ref:
event = self.get_event_from_handle(event_ref.ref)
if (event
and event.type.is_death_fallback()
and event_ref.role.is_primary()):
return event
return None