Package gen :: Package lib :: Module childref
[frames] | no frames]

Source Code for Module gen.lib.childref

  1  # 
  2  # Gramps - a GTK+/GNOME based genealogy program 
  3  # 
  4  # Copyright (C) 2006-2007  Donald N. Allingham 
  5  # 
  6  # This program is free software; you can redistribute it and/or modify 
  7  # it under the terms of the GNU General Public License as published by 
  8  # the Free Software Foundation; either version 2 of the License, or 
  9  # (at your option) any later version. 
 10  # 
 11  # This program is distributed in the hope that it will be useful, 
 12  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
 13  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 14  # GNU General Public License for more details. 
 15  # 
 16  # You should have received a copy of the GNU General Public License 
 17  # along with this program; if not, write to the Free Software 
 18  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 19  # 
 20   
 21  # $Id: childref.py 10103 2008-02-24 13:55:55Z acraphae $ 
 22   
 23  """ 
 24  Child Reference class for GRAMPS. 
 25  """ 
 26  #------------------------------------------------------------------------- 
 27  # 
 28  # standard python modules 
 29  # 
 30  #------------------------------------------------------------------------- 
 31  from types import InstanceType 
 32   
 33  #------------------------------------------------------------------------- 
 34  # 
 35  # GRAMPS modules 
 36  # 
 37  #------------------------------------------------------------------------- 
 38  from gen.lib.secondaryobj import SecondaryObject 
 39  from gen.lib.privacybase import PrivacyBase 
 40  from gen.lib.srcbase import SourceBase 
 41  from gen.lib.notebase import NoteBase 
 42  from gen.lib.refbase import RefBase 
 43  from gen.lib.childreftype import ChildRefType 
 44   
 45  #------------------------------------------------------------------------- 
 46  # 
 47  # Person References for Person/Family 
 48  # 
 49  #------------------------------------------------------------------------- 
50 -class ChildRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase):
51 """ 52 Person reference class. 53 54 This class is for keeping information about how the person relates 55 to another person from the database, if not through family. 56 Examples would be: godparent, friend, etc. 57 """ 58
59 - def __init__(self, source=None):
60 PrivacyBase.__init__(self, source) 61 SourceBase.__init__(self, source) 62 NoteBase.__init__(self, source) 63 RefBase.__init__(self, source) 64 if source: 65 self.frel = source.frel 66 self.mrel = source.mrel 67 else: 68 self.frel = ChildRefType() 69 self.mrel = ChildRefType()
70
71 - def serialize(self):
72 """ 73 Convert the object to a serialized tuple of data. 74 """ 75 return (PrivacyBase.serialize(self), 76 SourceBase.serialize(self), 77 NoteBase.serialize(self), 78 RefBase.serialize(self), 79 self.frel.serialize(), 80 self.mrel.serialize())
81
82 - def unserialize(self, data):
83 """ 84 Convert a serialized tuple of data to an object. 85 """ 86 (privacy, source_list, note_list, ref, frel, mrel) = data 87 PrivacyBase.unserialize(self, privacy) 88 SourceBase.unserialize(self, source_list) 89 NoteBase.unserialize(self, note_list) 90 RefBase.unserialize(self, ref) 91 self.frel = InstanceType(ChildRefType) 92 self.frel.unserialize(frel) 93 self.mrel = InstanceType(ChildRefType) 94 self.mrel.unserialize(mrel) 95 return self
96
97 - def get_text_data_list(self):
98 """ 99 Return the list of all textual attributes of the object. 100 101 @return: Returns the list of all textual attributes of the object. 102 @rtype: list 103 """ 104 return [str(self.frel), str(self.mrel)]
105
106 - def get_text_data_child_list(self):
107 """ 108 Return the list of child objects that may carry textual data. 109 110 @return: Returns the list of child objects that may carry textual data. 111 @rtype: list 112 """ 113 return self.source_list
114
115 - def get_note_child_list(self):
116 """ 117 Return the list of child secondary objects that may refer notes. 118 119 @return: Returns the list of child secondary child objects that may 120 refer notes. 121 @rtype: list 122 """ 123 return self.source_list
124
125 - def get_referenced_handles(self):
126 """ 127 Return the list of (classname, handle) tuples for all directly 128 referenced primary objects. 129 130 @return: List of (classname, handle) tuples for referenced objects. 131 @rtype: list 132 """ 133 ret = self.get_referenced_note_handles() 134 if self.ref: 135 ret += [('Person', self.ref)] 136 return ret
137
138 - def get_handle_referents(self):
139 """ 140 Return the list of child objects which may, directly or through their 141 children, reference primary objects.. 142 143 @return: Returns the list of objects refereincing primary objects. 144 @rtype: list 145 """ 146 return self.source_list
147
148 - def set_mother_relation(self, rel):
149 """Set relation between the person and mother.""" 150 self.mrel.set(rel)
151
152 - def get_mother_relation(self):
153 """Return the relation between the person and mother.""" 154 return self.mrel
155
156 - def set_father_relation(self, frel):
157 """Set relation between the person and father.""" 158 self.frel.set(frel)
159
160 - def get_father_relation(self):
161 """Return the relation between the person and father.""" 162 return self.frel
163