Start of better LDS support

svn: r6261
This commit is contained in:
Don Allingham
2006-04-04 18:07:23 +00:00
parent 82e6106da0
commit f3af587b75
15 changed files with 593 additions and 154 deletions

View File

@@ -19,6 +19,7 @@ pkgdata_PYTHON = \
_Family.py\
_GenderStats.py\
__init__.py\
_LdsOrdBase.py\
_LdsOrd.py\
_LocationBase.py\
_Location.py\

View File

@@ -41,13 +41,14 @@ from _SourceNote import SourceNote
from _MediaBase import MediaBase
from _AttributeBase import AttributeBase
from _EventRef import EventRef
from _LdsOrdBase import LdsOrdBase
#-------------------------------------------------------------------------
#
# Family class
#
#-------------------------------------------------------------------------
class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase):
class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase,LdsOrdBase):
"""
Introduction
============
@@ -85,6 +86,7 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase):
SourceNote.__init__(self)
MediaBase.__init__(self)
AttributeBase.__init__(self)
LdsOrdBase.__init__(self)
self.father_handle = None
self.mother_handle = None
self.child_list = []
@@ -118,7 +120,8 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase):
[er.serialize() for er in self.event_ref_list],
MediaBase.serialize(self),
AttributeBase.serialize(self),
lds_seal,SourceNote.serialize(self),
LdsOrdBase.serialize(self),
SourceNote.serialize(self),
self.change, self.marker, self.private)
def unserialize(self, data):
@@ -128,7 +131,7 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase):
"""
(self.handle, self.gramps_id, self.father_handle, self.mother_handle,
self.child_list, self.type,
event_ref_list, media_list, attribute_list, lds_seal, sn,
event_ref_list, media_list, attribute_list, lds_seal_list, sn,
self.change,self.marker, self.private) = data
self.event_ref_list = [EventRef().unserialize(er)
@@ -136,6 +139,7 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase):
MediaBase.unserialize(self,media_list)
AttributeBase.unserialize(self,attribute_list)
SourceNote.unserialize(self,sn)
LdsOrdBase.unserialize(self,lds_seal_list)
def _has_handle_reference(self,classname,handle):
if classname == 'Event':
@@ -143,7 +147,7 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase):
elif classname == 'Person':
return handle in self.child_list + [self.father_handle,self.mother_handle]
elif classname == 'Place':
return bool(self.lds_seal) and self.lds_seal.place == handle
return handle in [ x.place for x in self.lds_ord_list ]
return False
def _remove_handle_references(self,classname,handle_list):
@@ -160,8 +164,9 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase):
if self.mother_handle in handle_list:
self.mother_handle = None
elif classname == 'Place':
if self.lds_seal and self.lds_seal.place in handle_list:
self.lds_seal.place = None
for x in self.lds_ord_list:
if x.place in handle_list:
x.place = None
def _replace_handle_reference(self,classname,old_handle,new_handle):
if classname == 'Event':
@@ -179,8 +184,9 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase):
if self.mother_handle == old_handle:
self.mother_handle = new_handle
elif classname == 'Place':
if self.lds_seal and self.lds_seal.place == old_handle:
self.lds_seal.place = new_handle
for x in self.lds_ord_list:
if x.place == old_handle:
x.place = new_handle
def get_text_data_list(self):
"""
@@ -198,7 +204,7 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase):
@return: Returns the list of child objects that may carry textual data.
@rtype: list
"""
check_list = [self.lds_seal,self.note]
check_list = self.lds_ord_list + [self.note]
add_list = [item for item in check_list if item]
return self.media_list + self.attribute_list + \
self.source_list + add_list
@@ -210,9 +216,7 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase):
@return: Returns the list of child secondary child objects that may refer sources.
@rtype: list
"""
check_list = self.media_list + self.attribute_list
if self.lds_seal:
check_list.append(self.lds_seal)
check_list = self.media_list + self.attribute_list + self.lds_ord_list
return check_list
def get_referenced_handles(self):
@@ -262,26 +266,6 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase):
"""
return self.complete
def set_lds_sealing(self,lds_ord):
"""
Sets the LDS Sealing ordinance. An ordinance can be removed
by assigning to None.
@param lds_ord: L{LdsOrd} to assign as the LDS Sealing ordinance.
@type lds_ord: L{LdsOrd}
"""
self.lds_seal = lds_ord
def get_lds_sealing(self):
"""
Returns the LDS Sealing ordinance.
@returns: returns the L{LdsOrd} instance assigned as the LDS
Sealing ordinance, or None if no ordinance has been assigned.
@rtype: L{LdsOrd}
"""
return self.lds_seal
def set_relationship(self,relationship_type):
"""
Sets the relationship type between the people identified as the

View File

@@ -32,13 +32,14 @@ LDS Ordinance class for GRAMPS
from _SourceNote import SourceNote
from _DateBase import DateBase
from _PlaceBase import PlaceBase
from _PrivacyBase import PrivacyBase
#-------------------------------------------------------------------------
#
# LDS Ordinance class
#
#-------------------------------------------------------------------------
class LdsOrd(SourceNote,DateBase,PlaceBase):
class LdsOrd(SourceNote,DateBase,PlaceBase,PrivacyBase):
"""
Class that contains information about LDS Ordinances. LDS
ordinances are similar to events, but have very specific additional
@@ -46,17 +47,26 @@ class LdsOrd(SourceNote,DateBase,PlaceBase):
of Latter Day Saints (Morman church). The LDS church is the largest
source of genealogical information in the United States.
"""
BAPTISM = 0
ENDOWMENT = 1
SEAL_TO_PARENTS = 2
SEAL_TO_SPOUSE = 3
def __init__(self,source=None):
"""Creates a LDS Ordinance instance"""
SourceNote.__init__(self,source)
DateBase.__init__(self,source)
PlaceBase.__init__(self,source)
PrivacyBase.__init__(self,source)
if source:
self.type = source.type
self.famc = source.famc
self.temple = source.temple
self.status = source.status
else:
self.type = self.BAPTISM
self.famc = None
self.temple = ""
self.status = 0
@@ -117,6 +127,12 @@ class LdsOrd(SourceNote,DateBase,PlaceBase):
"""
return self.source_list
def get_type(self):
return self.type
def set_type(self, ord_type):
self.type = ord_type
def set_family_handle(self,family):
"""Sets the Family database handle associated with the LDS ordinance"""
self.famc = family

108
src/RelLib/_LdsOrdBase.py Normal file
View File

@@ -0,0 +1,108 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2006 Donald N. Allingham
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id: _LdsOrdBase.py 5875 2006-02-03 22:03:53Z rshura $
"""
LdsOrdBase class for GRAMPS
"""
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _LdsOrd import LdsOrd
#-------------------------------------------------------------------------
#
# LdsOrdBase classes
#
#-------------------------------------------------------------------------
class LdsOrdBase:
"""
Base class for lds_ord-aware objects.
"""
def __init__(self,source=None):
"""
Initialize a LdsOrdBase. If the source is not None, then object
is initialized from values of the source object.
@param source: Object used to initialize the new object
@type source: LdsOrdBase
"""
if source:
self.lds_ord_list = [ LdsOrd(lds_ord) \
for lds_ord in source.lds_ord_list ]
else:
self.lds_ord_list = []
def serialize(self):
return [addr.serialize() for addr in self.lds_ord_list]
def unserialize(self,data):
self.lds_ord_list = [LdsOrd().unserialize(item) for item in data]
def add_lds_ord(self,lds_ord):
"""
Adds the L{LdsOrd} instance to the object's list of lds_ordes
@param lds_ord: L{LdsOrd} instance to add to the object's lds_ord list
@type lds_ord: list
"""
self.lds_ord_list.append(lds_ord)
def remove_lds_ord(self,lds_ord):
"""
Removes the specified L{LdsOrd} instance from the lds_ord list
If the instance does not exist in the list, the operation has
no effect.
@param lds_ord: L{LdsOrd} instance to remove from the list
@type lds_ord: L{LdsOrd}
@return: True if the lds_ord was removed, False if it was not in the list.
@rtype: bool
"""
if lds_ord in self.lds_ord_list:
self.lds_ord_list.remove(lds_ord)
return True
else:
return False
def get_lds_ord_list(self):
"""
Returns the list of L{LdsOrd} instances associated with the object
@return: Returns the list of L{LdsOrd} instances
@rtype: list
"""
return self.lds_ord_list
def set_lds_ord_list(self,lds_ord_list):
"""
Assigns the passed list to the object's list of L{LdsOrd} instances.
@param lds_ord_list: List of L{LdsOrd} instances to be associated
with the object
@type lds_ord_list: list
"""
self.lds_ord_list = lds_ord_list

View File

@@ -41,6 +41,7 @@ from _SourceNote import SourceNote
from _MediaBase import MediaBase
from _AttributeBase import AttributeBase
from _AddressBase import AddressBase
from _LdsOrdBase import LdsOrdBase
from _UrlBase import UrlBase
from _Name import Name
from _EventRef import EventRef
@@ -52,7 +53,7 @@ from _LdsOrd import LdsOrd
#
#-------------------------------------------------------------------------
class Person(PrimaryObject,SourceNote,
MediaBase,AttributeBase,AddressBase,UrlBase):
MediaBase,AttributeBase,AddressBase,UrlBase,LdsOrdBase):
"""
Introduction
============
@@ -101,6 +102,7 @@ class Person(PrimaryObject,SourceNote,
AttributeBase.__init__(self)
AddressBase.__init__(self)
UrlBase.__init__(self)
LdsOrdBase.__init__(self)
self.primary_name = Name()
self.event_ref_list = []
self.family_list = []
@@ -110,9 +112,6 @@ class Person(PrimaryObject,SourceNote,
self.gender = Person.UNKNOWN
self.death_ref = None
self.birth_ref = None
self.lds_bapt = None
self.lds_endow = None
self.lds_seal = None
if data:
self.unserialize(data)
@@ -145,32 +144,26 @@ class Person(PrimaryObject,SourceNote,
death_ref = None
else:
death_ref = self.death_ref.serialize()
if self.lds_bapt == None:
lds_bapt = None
else:
lds_bapt = self.lds_bapt.serialize()
if self.lds_endow == None:
lds_endow = None
else:
lds_endow = self.lds_endow.serialize()
if self.lds_seal == None:
lds_seal = None
else:
lds_seal = self.lds_seal.serialize()
return (self.handle, self.gramps_id, self.gender,
return (self.handle,
self.gramps_id,
self.gender,
self.primary_name.serialize(),
[name.serialize() for name in self.alternate_names],
unicode(self.nickname), death_ref, birth_ref,
unicode(self.nickname),
death_ref,
birth_ref,
[er.serialize() for er in self.event_ref_list],
self.family_list,self.parent_family_list,
self.family_list,
self.parent_family_list,
MediaBase.serialize(self),
AddressBase.serialize(self),
AttributeBase.serialize(self),
UrlBase.serialize(self),
lds_bapt, lds_endow, lds_seal,
LdsOrdBase.serialize(self),
SourceNote.serialize(self),
self.change, self.marker,
self.change,
self.marker,
self.private)
def unserialize(self,data):
@@ -182,30 +175,38 @@ class Person(PrimaryObject,SourceNote,
Person object
@type data: tuple
"""
(self.handle, self.gramps_id, self.gender, primary_name,
alternate_names, self.nickname, death_ref,
birth_ref, event_ref_list, self.family_list,
self.parent_family_list, media_list, address_list,
attribute_list, urls, lds_bapt, lds_endow,
lds_seal, sn, self.change,
self.marker, self.private) = (data + (False,))[0:22]
(self.handle,
self.gramps_id,
self.gender,
primary_name,
alternate_names,
self.nickname,
death_ref,
birth_ref,
event_ref_list,
self.family_list,
self.parent_family_list,
media_list,
address_list,
attribute_list,
urls,
lds_ord_list,
sn,
self.change,
self.marker,
self.private) = data
self.primary_name.unserialize(primary_name)
if death_ref:
self.death_ref = EventRef().unserialize(death_ref)
if birth_ref:
self.birth_ref = EventRef().unserialize(birth_ref)
if lds_bapt:
self.lds_bapt = LdsOrd().unserialize(lds_bapt)
if lds_endow:
self.lds_endow = LdsOrd().unserialize(lds_endow)
if lds_seal:
self.lds_seal = LdsOrd().unserialize(lds_seal)
self.alternate_names = [Name().unserialize(name)
for name in alternate_names]
self.event_ref_list = [EventRef().unserialize(er)
for er in event_ref_list]
MediaBase.unserialize(self,media_list)
LdsOrdBase.unserialize(self,lds_ord_list)
AddressBase.unserialize(self,address_list)
AttributeBase.unserialize(self,attribute_list)
UrlBase.unserialize(self,urls)
@@ -221,9 +222,7 @@ class Person(PrimaryObject,SourceNote,
return handle in self.family_list + \
[item[0] for item in self.parent_family_list ]
elif classname == 'Place':
return handle in [ordinance.place
for ordinance in [self.lds_bapt,self.lds_endow,self.lds_seal]
if ordinance]
return handle in self.lds_ord_list
return False
def _remove_handle_references(self,classname,handle_list):
@@ -243,7 +242,7 @@ class Person(PrimaryObject,SourceNote,
if item[0] not in handle_list ]
self.parent_family_list = new_list
elif classname == 'Place':
for ordinance in [self.lds_bapt,self.lds_endow,self.lds_seal]:
for ordinance in self.lds_ord_list:
if ordinance.place in handle_list:
ordinance.place = None
@@ -271,7 +270,7 @@ class Person(PrimaryObject,SourceNote,
new_list.append(item)
self.parent_family_list = new_list
elif classname == 'Place':
for ordinance in [self.lds_bapt,self.lds_endow,self.lds_seal]:
for ordinance in self.lds_ord_list:
if ordinance.place == old_handle:
ordinance.place = new_handle
@@ -291,7 +290,7 @@ class Person(PrimaryObject,SourceNote,
@return: Returns the list of child objects that may carry textual data.
@rtype: list
"""
check_list = [self.lds_bapt,self.lds_endow,self.lds_seal,self.note]
check_list = self.lds_ord_list + [self.note]
add_list = [item for item in check_list if item]
return [self.primary_name] + self.media_list + \
self.alternate_names + self.address_list + \
@@ -305,11 +304,9 @@ class Person(PrimaryObject,SourceNote,
@return: Returns the list of child secondary child objects that may refer sources.
@rtype: list
"""
lds_list = [self.lds_bapt,self.lds_endow,self.lds_seal]
lds_check_list = [item for item in lds_list if item]
return [self.primary_name] + self.media_list + \
self.alternate_names + self.address_list + \
self.attribute_list + lds_check_list
self.attribute_list + self.lds_ord_list
def get_referenced_handles(self):
"""
@@ -825,63 +822,3 @@ class Person(PrimaryObject,SourceNote,
return None
else:
return self.parent_family_list[0][0]
def set_lds_baptism(self,lds_ord):
"""
Sets the LDS Baptism ordinance. An ordinance can be removed
by assigning to None.
@param lds_ord: L{LdsOrd} to assign as the LDS Baptism ordinance.
@type lds_ord: L{LdsOrd}
"""
self.lds_bapt = lds_ord
def get_lds_baptism(self):
"""
Returns the LDS Baptism ordinance.
@returns: returns the L{LdsOrd} instance assigned as the LDS
Baptism ordinance, or None if no ordinance has been assigned.
@rtype: L{LdsOrd}
"""
return self.lds_bapt
def set_lds_endowment(self,lds_ord):
"""
Sets the LDS Endowment ordinance. An ordinance can be removed
by assigning to None.
@param lds_ord: L{LdsOrd} to assign as the LDS Endowment ordinance.
@type lds_ord: L{LdsOrd}
"""
self.lds_endow = lds_ord
def get_lds_endowment(self):
"""
Returns the LDS Endowment ordinance.
@returns: returns the L{LdsOrd} instance assigned as the LDS
Endowment ordinance, or None if no ordinance has been assigned.
@rtype: L{LdsOrd}
"""
return self.lds_endow
def set_lds_sealing(self,lds_ord):
"""
Sets the LDS Sealing ordinance. An ordinance can be removed
by assigning to None.
@param lds_ord: L{LdsOrd} to assign as the LDS Sealing ordinance.
@type lds_ord: L{LdsOrd}
"""
self.lds_seal = lds_ord
def get_lds_sealing(self):
"""
Returns the LDS Sealing ordinance.
@returns: returns the L{LdsOrd} instance assigned as the LDS
Sealing ordinance, or None if no ordinance has been assigned.
@rtype: L{LdsOrd}
"""
return self.lds_seal