* src/EditPerson.py: Support for event references.

* src/FamilyView.py: Support for event references.
* src/ListBox.py: Support for event references.
* src/PedView.py: Support for event references.
* src/RelLib.py: Support for event references.


svn: r4700
This commit is contained in:
Alex Roitman 2005-05-27 05:07:26 +00:00
parent 4b3ce014fd
commit 50ac810074
6 changed files with 208 additions and 146 deletions

View File

@ -1,6 +1,12 @@
2005-05-26 Alex Roitman <shura@gramps-project.org> 2005-05-26 Alex Roitman <shura@gramps-project.org>
* src/RelLib.py (EventRef): Add class. * src/RelLib.py (EventRef): Add class.
* src/EditPerson.py: Support for event references.
* src/FamilyView.py: Support for event references.
* src/ListBox.py: Support for event references.
* src/PedView.py: Support for event references.
* src/RelLib.py: Support for event references.
2005-05-26 Martin Hawlisch <Martin.Hawlisch@gmx.de> 2005-05-26 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/plugins/TestcaseGenerator.py: Add place, media and source * src/plugins/TestcaseGenerator.py: Add place, media and source
references. references.

View File

@ -201,8 +201,8 @@ class EditPerson:
self.prefix_label.set_text(_('Patronymic:')) self.prefix_label.set_text(_('Patronymic:'))
self.prefix_label.set_use_underline(True) self.prefix_label.set_use_underline(True)
self.birth_handle = person.get_birth_handle() self.birth_ref = person.get_birth_ref()
self.death_handle = person.get_death_handle() self.death_ref = person.get_death_ref()
self.pname = RelLib.Name(person.get_primary_name()) self.pname = RelLib.Name(person.get_primary_name())
@ -226,7 +226,7 @@ class EditPerson:
# event display # event display
self.event_box = ListBox.EventListBox( self.event_box = ListBox.EventListBox(
self, self.person, self.event_list, events_label, self, self.person, self.event_ref_list, events_label,
[event_add_btn,event_edit_btn,event_delete_btn]) [event_add_btn,event_edit_btn,event_delete_btn])
self.attr_box = ListBox.AttrListBox( self.attr_box = ListBox.AttrListBox(
@ -848,20 +848,20 @@ class EditPerson:
self.person.set_attribute_list(self.attr_box.data) self.person.set_attribute_list(self.attr_box.data)
self.person.set_address_list(self.addr_box.data) self.person.set_address_list(self.addr_box.data)
self.person.set_birth_handle(None) self.person.set_birth_ref(None)
self.person.set_death_handle(None) self.person.set_death_ref(None)
elist = self.event_box.data[:] eref_list = self.event_box.data[:]
for event in elist: for event_ref in eref_list:
if event_ref and event_ref.ref:
event = self.db.get_event_from_handle(event_ref.ref)
if event.get_name() == "Birth": if event.get_name() == "Birth":
self.person.set_birth_handle(event.get_handle()) self.person.set_birth_ref(event_ref)
self.event_box.data.remove(event) self.event_box.data.remove(event_ref)
if event.get_name() == "Death": if event.get_name() == "Death":
self.person.set_death_handle(event.get_handle()) self.person.set_death_ref(event_ref)
self.event_box.data.remove(event) self.event_box.data.remove(event_ref)
elist = [] eref_list = [event_ref for event_ref in self.event_box.data]
for val in self.event_box.data: self.person.set_event_ref_list(eref_list)
elist.append(val.get_handle())
self.person.set_event_list(elist)
def on_apply_person_clicked(self,obj): def on_apply_person_clicked(self,obj):
@ -1193,8 +1193,8 @@ class EditPerson:
for i in range(len(list)): for i in range(len(list)):
child_handle = list[i] child_handle = list[i]
child = self.db.get_person_from_handle(child_handle) child = self.db.get_person_from_handle(child_handle)
if child.get_birth_handle(): if child.get_birth_ref():
event = self.db.get_event_from_handle(child.get_birth_handle()) event = self.db.get_event_from_handle(child.get_birth_ref().ref)
child_date = event.get_date_object().get_sort_value() child_date = event.get_date_object().get_sort_value()
else: else:
continue continue
@ -1213,9 +1213,9 @@ class EditPerson:
return(list) return(list)
# Build the person's date string once # Build the person's date string once
event_handle = person.get_birth_handle() event_ref = person.get_birth_ref()
if event_handle: if event_ref:
event = self.db.get_event_from_handle(event_handle) event = self.db.get_event_from_handle(event_ref.ref)
person_bday = event.get_date_object().get_sort_value() person_bday = event.get_date_object().get_sort_value()
else: else:
person_bday = 0 person_bday = 0
@ -1226,9 +1226,9 @@ class EditPerson:
target = index target = index
for i in range(index-1, -1, -1): for i in range(index-1, -1, -1):
other = self.db.get_person_from_handle(list[i]) other = self.db.get_person_from_handle(list[i])
event_handle = other.get_birth_handle() event_ref = other.get_birth_ref()
if event_handle: if event_ref:
event = self.db.get_event_from_handle(event_handle) event = self.db.get_event_from_handle(event_ref.ref)
other_bday = event.get_date_object().get_sort_value() other_bday = event.get_date_object().get_sort_value()
if other_bday == 0: if other_bday == 0:
continue; continue;
@ -1241,9 +1241,9 @@ class EditPerson:
if (target == index): if (target == index):
for i in range(index, len(list)): for i in range(index, len(list)):
other = self.db.get_person_from_handle(list[i]) other = self.db.get_person_from_handle(list[i])
event_handle = other.get_birth_handle() event_ref = other.get_birth_ref()
if event_handle: if event_ref:
event = self.db.get_event_from_handle(event_handle) event = self.db.get_event_from_handle(event_ref.ref)
other_bday = event.get_date_object().get_sort_value() other_bday = event.get_date_object().get_sort_value()
if other_bday == "99999999": if other_bday == "99999999":
continue; continue;

View File

@ -977,10 +977,16 @@ class FamilyView:
return return
person = self.person person = self.person
bhandle = person.get_birth_handle() bref = person.get_birth_ref()
dhandle = person.get_death_handle() dref = person.get_death_ref()
bd = self.parent.db.get_event_from_handle(bhandle) if bref:
dd = self.parent.db.get_event_from_handle(dhandle) bd = self.parent.db.get_event_from_handle(bref.ref)
else:
bd = None
if dref:
dd = self.parent.db.get_event_from_handle(dref.ref)
else:
dd = None
if bd and dd: if bd and dd:
n = "%s [%s]\n\t%s %s\n\t%s %s " % ( n = "%s [%s]\n\t%s %s\n\t%s %s " % (
@ -1596,10 +1602,10 @@ class FamilyView:
for i in range(len(list)): for i in range(len(list)):
child_handle = list[i] child_handle = list[i]
child = self.parent.db.get_person_from_handle(child_handle) child = self.parent.db.get_person_from_handle(child_handle)
birth_handle = child.get_birth_handle() birth_ref = child.get_birth_ref()
birth = self.parent.db.get_event_from_handle(birth_handle) if not birth_ref:
if not birth:
continue continue
birth = self.parent.db.get_event_from_handle(birth_ref.ref)
child_date = birth.get_date_object().get_sort_value() child_date = birth.get_date_object().get_sort_value()
if child_date == 0: if child_date == 0:
continue continue

View File

@ -245,14 +245,14 @@ class EventListBox(ReorderListBox):
self.trans = TransTable.TransTable(self.titles) self.trans = TransTable.TransTable(self.titles)
self.data = [] self.data = []
if person.get_birth_handle(): if person.get_birth_ref():
event = parent.db.get_event_from_handle(person.get_birth_handle()) event = parent.db.get_event_from_handle(person.get_birth_ref().ref)
self.data.append(event) self.data.append(event)
if person.get_death_handle(): if person.get_death_ref():
event = parent.db.get_event_from_handle(person.get_death_handle()) event = parent.db.get_event_from_handle(person.get_death_ref().ref)
self.data.append(event) self.data.append(event)
for val in person.get_event_list(): for event_ref in person.get_event_ref_list():
self.data.append(parent.db.get_event_from_handle(val)) self.data.append(parent.db.get_event_from_handle(event_ref.ref))
eventnames = const.personalEvents eventnames = const.personalEvents

View File

@ -717,16 +717,18 @@ class PedigreeView:
name = NameDisplay.displayer.display(person) name = NameDisplay.displayer.display(person)
if line_count < 3: if line_count < 3:
return name return name
birth = self.db.get_event_from_handle( person.get_birth_handle()) birth_ref = person.get_birth_ref()
bd="" bd=""
bp="" bp=""
if birth: if birth_ref:
birth = self.db.get_event_from_handle(birth_ref.ref)
bd = birth.get_date() bd = birth.get_date()
bp = self.get_place_name(birth.get_place_handle()) bp = self.get_place_name(birth.get_place_handle())
death = self.db.get_event_from_handle( person.get_death_handle()) death_ref = person.get_death_ref()
dd="" dd=""
dp="" dp=""
if death: if death_ref:
death = self.db.get_event_from_handle(death_ref.ref)
dd = death.get_date() dd = death.get_date()
dp = self.get_place_name(death.get_place_handle()) dp = self.get_place_name(death.get_place_handle())
if line_count < 5: if line_count < 5:
@ -800,12 +802,13 @@ def build_detail_string(db,person):
return u"\n%s %s" % (label,ed) return u"\n%s %s" % (label,ed)
birth_handle = person.get_birth_handle() birth_ref = person.get_birth_ref()
if birth_handle: if birth_ref:
detail_text += format_event(db, _BORN, db.get_event_from_handle(birth_handle)) detail_text += format_event(db, _BORN,
db.get_event_from_handle(birth_ref.ref))
else: else:
for event_handle in person.get_event_list(): for event_ref in person.get_event_ref_list():
event = db.get_event_from_handle(event_handle) event = db.get_event_from_handle(event_ref.ref)
if event and event.get_name() == "Baptism": if event and event.get_name() == "Baptism":
detail_text += format_event(db, _BAPT, event) detail_text += format_event(db, _BAPT, event)
break break
@ -813,12 +816,13 @@ def build_detail_string(db,person):
detail_text += format_event(db, _CHRI, event) detail_text += format_event(db, _CHRI, event)
break break
death_handle = person.get_death_handle() death_ref = person.get_death_ref()
if death_handle: if death_ref:
detail_text += format_event(db, _DIED, db.get_event_from_handle(death_handle)) detail_text += format_event(db, _DIED,
db.get_event_from_handle(death_ref.ref))
else: else:
for event_handle in person.get_event_list(): for event_ref in person.get_event_ref_list():
event = db.get_event_from_handle(event_handle) event = db.get_event_from_handle(event_ref.ref)
if event and event.get_name() == "Burial": if event and event.get_name() == "Burial":
detail_text += format_event(db, _BURI, event) detail_text += format_event(db, _BURI, event)
break break

View File

@ -918,14 +918,14 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase):
MediaBase.__init__(self) MediaBase.__init__(self)
AttributeBase.__init__(self) AttributeBase.__init__(self)
self.primary_name = Name() self.primary_name = Name()
self.event_list = [] self.event_ref_list = []
self.family_list = [] self.family_list = []
self.parent_family_list = [] self.parent_family_list = []
self.nickname = "" self.nickname = ""
self.alternate_names = [] self.alternate_names = []
self.gender = Person.UNKNOWN self.gender = Person.UNKNOWN
self.death_handle = None self.death_ref = None
self.birth_handle = None self.birth_ref = None
self.address_list = [] self.address_list = []
self.urls = [] self.urls = []
self.lds_bapt = None self.lds_bapt = None
@ -956,8 +956,8 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase):
""" """
return (self.handle, self.gramps_id, self.gender, return (self.handle, self.gramps_id, self.gender,
self.primary_name, self.alternate_names, self.primary_name, self.alternate_names,
unicode(self.nickname), self.death_handle, self.birth_handle, unicode(self.nickname), self.death_ref, self.birth_ref,
self.event_list, self.family_list, self.parent_family_list, self.event_ref_list, self.family_list, self.parent_family_list,
self.media_list, self.address_list, self.attribute_list, self.media_list, self.address_list, self.attribute_list,
self.urls, self.lds_bapt, self.lds_endow, self.lds_seal, self.urls, self.lds_bapt, self.lds_endow, self.lds_seal,
self.complete, self.source_list, self.note, self.change, self.complete, self.source_list, self.note, self.change,
@ -973,8 +973,8 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase):
@type data: tuple @type data: tuple
""" """
(self.handle, self.gramps_id, self.gender, self.primary_name, (self.handle, self.gramps_id, self.gender, self.primary_name,
self.alternate_names, self.nickname, self.death_handle, self.alternate_names, self.nickname, self.death_ref,
self.birth_handle, self.event_list, self.family_list, self.birth_ref, self.event_ref_list, self.family_list,
self.parent_family_list, self.media_list, self.address_list, self.parent_family_list, self.media_list, self.address_list,
self.attribute_list, self.urls, self.lds_bapt, self.lds_endow, self.attribute_list, self.urls, self.lds_bapt, self.lds_endow,
self.lds_seal, self.complete, self.source_list, self.note, self.lds_seal, self.complete, self.source_list, self.note,
@ -982,7 +982,10 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase):
def _has_handle_reference(self,classname,handle): def _has_handle_reference(self,classname,handle):
if classname == 'Event': if classname == 'Event':
return handle in self.event_list + [self.birth_handle,self.death_handle] return handle in [ref.ref for ref in
self.event_ref_list + [self.birth_ref,
self.death_ref]
if ref]
elif classname == 'Family': elif classname == 'Family':
return handle in self.family_list + \ return handle in self.family_list + \
[item[0] for item in self.parent_family_list ] [item[0] for item in self.parent_family_list ]
@ -994,13 +997,13 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase):
def _remove_handle_references(self,classname,handle_list): def _remove_handle_references(self,classname,handle_list):
if classname == 'Event': if classname == 'Event':
new_list = [ handle for handle in self.event_list \ new_list = [ ref for ref in self.event_ref_list \
if handle not in handle_list ] if ref and ref.ref not in handle_list ]
self.event_list = new_list self.event_ref_list = new_list
if self.death_handle and self.death_handle in handle_list: if self.death_ref and self.death_ref.ref in handle_list:
self.death_handle = None self.death_ref = None
if self.birth_handle and self.birth_handle in handle_list: if self.birth_ref and self.birth_ref.ref in handle_list:
self.birth_handle = None self.birth_ref = None
elif classname == 'Family': elif classname == 'Family':
new_list = [ handle for handle in self.family_list \ new_list = [ handle for handle in self.family_list \
if handle not in handle_list ] if handle not in handle_list ]
@ -1015,13 +1018,15 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase):
def _replace_handle_reference(self,classname,old_handle,new_handle): def _replace_handle_reference(self,classname,old_handle,new_handle):
if classname == 'Event': if classname == 'Event':
while old_handle in self.event_list: handle_list = [ref.ref for ref in self.event_ref_list]
ix = self.event_list.index(old_handle) while old_handle in handle_list:
self.event_list[ix] = new_handle ix = handle_list.index(old_handle)
if self.death_handle and self.death_handle == old_handle: self.event_ref_list[ix].ref = new_handle
self.death_handle = new_handle handle_list[ix] = ''
if self.birth_handle and self.birth_handle == old_handle: if self.death_ref and self.death_ref.ref == old_handle:
self.birth_handle = new_handle self.death_ref.ref = new_handle
if self.birth_ref and self.birth_ref.ref == old_handle:
self.birth_ref.ref = new_handle
elif classname == 'Family': elif classname == 'Family':
while old_handle in self.family_list: while old_handle in self.family_list:
ix = self.family_list.index(old_handle) ix = self.family_list.index(old_handle)
@ -1084,9 +1089,9 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase):
@rtype: list @rtype: list
""" """
ret = [] ret = []
ret += [('Event',handle) for handle in ret += [('Event',ref.ref) for ref in
self.event_list + [self.birth_handle,self.death_handle] self.event_ref_list + [self.birth_ref,self.death_ref]
if handle] if ref]
ret += [('Family',handle) for handle in self.family_list ret += [('Family',handle) for handle in self.family_list
+ [item[0] for item in self.parent_family_list]] + [item[0] for item in self.parent_family_list]]
return ret return ret
@ -1250,80 +1255,83 @@ class Person(PrimaryObject,PrivateSourceNote,MediaBase,AttributeBase):
""" """
return self.gender return self.gender
def set_birth_handle(self,event_handle): def set_birth_ref(self,event_ref):
""" """
Assigns the birth event to the Person object. This is accomplished Assigns the birth event to the Person object. This is accomplished
by assigning the handle of a valid L{Event} in the current database. by assigning the L{EventRef} of the birth event in the current
database.
@param event_handle: handle of the L{Event} to be associated with @param event_ref: the L{EventRef} object associated with
the Person's birth. the Person's birth.
@type event_handle: str @type event_handle: EventRef
""" """
self.birth_handle = event_handle self.birth_ref = event_ref
def set_death_handle(self,event_handle): def set_death_ref(self,event_ref):
""" """
Assigns the death event to the Person object. This is accomplished Assigns the death event to the Person object. This is accomplished
by assigning the handle of a valid L{Event} in the current database. by assigning the L{EventRef} of the death event in the current
database.
@param event_handle: handle of the L{Event} to be associated with @param event_ref: the L{EventRef} object associated with
the Person's death. the Person's death.
@type event_handle: str @type event_handle: EventRef
""" """
self.death_handle = event_handle self.death_ref = event_ref
def get_birth_handle(self): def get_birth_ref(self):
""" """
Returns the database handle for the Person's birth event. This Returns the L{EventRef} for Person's birth event. This
should correspond to an L{Event} in the database's L{Event} list. should correspond to an L{Event} in the database's L{Event} list.
@returns: Returns the birth L{Event} handle or None if no birth @returns: Returns the birth L{EventRef} or None if no birth
L{Event} has been assigned. L{Event} has been assigned.
@rtype: str @rtype: EventRef
""" """
return self.birth_handle return self.birth_ref
def get_death_handle(self): def get_death_ref(self):
""" """
Returns the database handle for the Person's death event. This Returns the L{EventRef} for the Person's death event. This
should correspond to an L{Event} in the database's L{Event} list. should correspond to an L{Event} in the database's L{Event} list.
@returns: Returns the death L{Event} handle or None if no death @returns: Returns the death L{EventRef} or None if no death
L{Event} has been assigned. L{Event} has been assigned.
@rtype: str @rtype: event_ref
""" """
return self.death_handle return self.death_ref
def add_event_handle(self,event_handle): def add_event_ref(self,event_ref):
""" """
Adds the L{Event} to the Person instance's L{Event} list. This is Adds the L{EventRef} to the Person instance's L{EventRef} list.
accomplished by assigning the handle of a valid L{Event} in the This is accomplished by assigning the L{EventRef} of a valid
current database. L{Event} in the current database.
@param event_handle: handle of the L{Event} to be added to the @param event_ref: the L{EventRef} to be added to the
Person's L{Event} list. Person's L{EventRef} list.
@type event_handle: str @type event_ref: EventRef
""" """
self.event_list.append(event_handle) self.event_ref_list.append(event_ref)
def get_event_list(self): def get_event_ref_list(self):
""" """
Returns the list of handles associated with L{Event} instances. Returns the list of L{EventRef} objects associated with L{Event}
instances.
@returns: Returns the list of L{Event} handles associated with @returns: Returns the list of L{EventRef} objects associated with
the Person instance. the Person instance.
@rtype: list @rtype: list
""" """
return self.event_list return self.event_ref_list
def set_event_list(self,event_list): def set_event_ref_list(self,event_ref_list):
""" """
Sets the Person instance's L{Event} list to the passed list. Sets the Person instance's L{EventRef} list to the passed list.
@param event_list: List of valid L{Event} handles @param event_ref_list: List of valid L{EventRef} objects
@type event_list: list @type event_ref_list: list
""" """
self.event_list = event_list self.event_ref_list = event_ref_list
def add_family_handle(self,family_handle): def add_family_handle(self,family_handle):
""" """
@ -1697,7 +1705,7 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase):
self.mother_handle = None self.mother_handle = None
self.child_list = [] self.child_list = []
self.type = Family.MARRIED self.type = Family.MARRIED
self.event_list = [] self.event_ref_list = []
self.lds_seal = None self.lds_seal = None
self.complete = 0 self.complete = 0
@ -1718,7 +1726,7 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase):
@rtype: tuple @rtype: tuple
""" """
return (self.handle, self.gramps_id, self.father_handle, self.mother_handle, return (self.handle, self.gramps_id, self.father_handle, self.mother_handle,
self.child_list, self.type, self.event_list, self.child_list, self.type, self.event_ref_list,
self.media_list, self.attribute_list, self.lds_seal, self.media_list, self.attribute_list, self.lds_seal,
self.complete, self.source_list, self.note, self.complete, self.source_list, self.note,
self.change) self.change)
@ -1729,13 +1737,13 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase):
back into the data in a Family structure. back into the data in a Family structure.
""" """
(self.handle, self.gramps_id, self.father_handle, self.mother_handle, (self.handle, self.gramps_id, self.father_handle, self.mother_handle,
self.child_list, self.type, self.event_list, self.child_list, self.type, self.event_ref_list,
self.media_list, self.attribute_list, self.lds_seal, self.media_list, self.attribute_list, self.lds_seal,
self.complete, self.source_list, self.note, self.change) = data self.complete, self.source_list, self.note, self.change) = data
def _has_handle_reference(self,classname,handle): def _has_handle_reference(self,classname,handle):
if classname == 'Event': if classname == 'Event':
return handle in self.event_list return handle in [ref.ref for ref in self.event_ref_list]
elif classname == 'Person': elif classname == 'Person':
return handle in self.child_list + [self.father_handle,self.mother_handle] return handle in self.child_list + [self.father_handle,self.mother_handle]
elif classname == 'Place': elif classname == 'Place':
@ -1744,9 +1752,9 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase):
def _remove_handle_references(self,classname,handle_list): def _remove_handle_references(self,classname,handle_list):
if classname == 'Event': if classname == 'Event':
new_list = [ handle for handle in self.event_list \ new_list = [ ref for ref in self.event_ref_list \
if handle not in handle_list ] if ref.ref not in handle_list ]
self.event_list = new_list self.event_ref_list = new_list
elif classname == 'Person': elif classname == 'Person':
new_list = [ handle for handle in self.child_list \ new_list = [ handle for handle in self.child_list \
if handle not in handle_list ] if handle not in handle_list ]
@ -1761,9 +1769,11 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase):
def _replace_handle_reference(self,classname,old_handle,new_handle): def _replace_handle_reference(self,classname,old_handle,new_handle):
if classname == 'Event': if classname == 'Event':
while old_handle in self.event_list: handle_list = [ref.ref for ref in self.event_ref_list]
ix = self.event_list.index(old_handle) while old_handle in handle_list:
self.event_list[ix] = new_handle ix = handle_list(old_handle)
self.event_ref_list[ix].ref = new_handle
handle_list[ix] = ''
elif classname == 'Person': elif classname == 'Person':
while old_handle in self.child_list: while old_handle in self.child_list:
ix = self.child_list.index(old_handle) ix = self.child_list.index(old_handle)
@ -1818,7 +1828,7 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase):
@rtype: list @rtype: list
""" """
ret = [] ret = []
ret += [('Event',handle) for handle in self.event_list] ret += [('Event',ref.ref) for ref in self.event_ref_list]
ret += [('Person',handle) for handle in ret += [('Person',handle) for handle in
self.child_list + [self.father_handle,self.mother_handle] self.child_list + [self.father_handle,self.mother_handle]
if handle] if handle]
@ -1999,36 +2009,37 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase):
""" """
self.child_list = child_list self.child_list = child_list
def add_event_handle(self,event_handle): def add_event_ref(self,event_ref):
""" """
Adds the L{Event} to the Family instance's L{Event} list. This is Adds the L{EventRef} to the Family instance's L{EventRef} list.
accomplished by assigning the handle of a valid L{Event} in the This is accomplished by assigning the L{EventRef} for the valid
current database. L{Event}in the current database.
@param event_handle: handle of the L{Event} to be added to the @param event_ref: the L{EventRef} to be added to the
Person's L{Event} list. Person's L{EventRef} list.
@type event_handle: str @type event_ref: EventRef
""" """
self.event_list.append(event_handle) self.event_ref_list.append(event_ref)
def get_event_list(self) : def get_event_ref_list(self) :
""" """
Returns the list of handles associated with L{Event} instances. Returns the list of L{EventRef} objects associated with L{Event}
instances.
@returns: Returns the list of L{Event} handles associated with @returns: Returns the list of L{EventRef} objects associated with
the Family instance. the Family instance.
@rtype: list @rtype: list
""" """
return self.event_list return self.event_ref_list
def set_event_list(self,event_list) : def set_event_ref_list(self,event_ref_list) :
""" """
Sets the Family instance's L{Event} list to the passed list. Sets the Family instance's L{EventRef} list to the passed list.
@param event_list: List of valid L{Event} handles @param event_ref_list: List of valid L{EventRef} objects
@type event_list: list @type event_ref_list: list
""" """
self.event_list = event_list self.event_ref_list = event_ref_list
class Event(PrimaryObject,PrivateSourceNote,MediaBase,DateBase,PlaceBase): class Event(PrimaryObject,PrivateSourceNote,MediaBase,DateBase,PlaceBase):
""" """
@ -4024,7 +4035,7 @@ class SourceRef(BaseObject,DateBase,PrivacyBase,NoteBase):
else: else:
return False return False
class EventRef: class EventRef(BaseObject,PrivacyBase,NoteBase):
""" """
Event reference class. Event reference class.
@ -4046,6 +4057,8 @@ class EventRef:
""" """
Creates a new EventRef instance, copying from the source if present. Creates a new EventRef instance, copying from the source if present.
""" """
PrivacyBase.__init__(self)
NoteBase.__init__(self)
if source: if source:
self.ref = source.ref self.ref = source.ref
self.role_int = source.role_int self.role_int = source.role_int
@ -4055,6 +4068,39 @@ class EventRef:
self.role_int = self.ROLE_CUSTOM self.role_int = self.ROLE_CUSTOM
self.role_str = "" self.role_str = ""
def get_text_data_list(self):
"""
Returns the list of all textual attributes of the object.
@return: Returns the list of all textual attributes of the object.
@rtype: list
"""
return [self.role_str]
def get_text_data_child_list(self):
"""
Returns the list of child objects that may carry textual data.
@return: Returns the list of child objects that may carry textual data.
@rtype: list
"""
if self.note:
return [self.note]
return []
def get_referenced_handles(self):
"""
Returns the list of (classname,handle) tuples for all directly
referenced primary objects.
@return: Returns the list of (classname,handle) tuples for referenced objects.
@rtype: list
"""
if self.ref:
return [('Event',self.ref)]
else:
return []
def get_reference_handle(self): def get_reference_handle(self):
""" """
Returns the handle of the referred Event object. Returns the handle of the referred Event object.