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

Source Code for Module gen.lib.personref

  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: personref.py 10103 2008-02-24 13:55:55Z acraphae $ 
 22   
 23  """ 
 24  Person Reference class for GRAMPS. 
 25  """ 
 26   
 27  #------------------------------------------------------------------------- 
 28  # 
 29  # GRAMPS modules 
 30  # 
 31  #------------------------------------------------------------------------- 
 32  from gen.lib.secondaryobj import SecondaryObject 
 33  from gen.lib.privacybase import PrivacyBase 
 34  from gen.lib.srcbase import SourceBase 
 35  from gen.lib.notebase import NoteBase 
 36  from gen.lib.refbase import RefBase 
 37   
 38  #------------------------------------------------------------------------- 
 39  # 
 40  # Person References for Person/Family 
 41  # 
 42  #------------------------------------------------------------------------- 
43 -class PersonRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase):
44 """ 45 Person reference class. 46 47 This class is for keeping information about how the person relates 48 to another person from the database, if not through family. 49 Examples would be: godparent, friend, etc. 50 """ 51
52 - def __init__(self, source=None):
53 PrivacyBase.__init__(self, source) 54 SourceBase.__init__(self, source) 55 NoteBase.__init__(self, source) 56 RefBase.__init__(self, source) 57 if source: 58 self.rel = source.rel 59 else: 60 self.rel = ''
61
62 - def serialize(self):
63 """ 64 Convert the object to a serialized tuple of data. 65 """ 66 return (PrivacyBase.serialize(self), 67 SourceBase.serialize(self), 68 NoteBase.serialize(self), 69 RefBase.serialize(self), 70 self.rel)
71
72 - def unserialize(self, data):
73 """ 74 Convert a serialized tuple of data to an object. 75 """ 76 (privacy, source_list, note_list, ref, self.rel) = data 77 PrivacyBase.unserialize(self, privacy) 78 SourceBase.unserialize(self, source_list) 79 NoteBase.unserialize(self, note_list) 80 RefBase.unserialize(self, ref) 81 return self
82
83 - def get_text_data_list(self):
84 """ 85 Return the list of all textual attributes of the object. 86 87 @return: Returns the list of all textual attributes of the object. 88 @rtype: list 89 """ 90 return [self.rel]
91
92 - def get_text_data_child_list(self):
93 """ 94 Return the list of child objects that may carry textual data. 95 96 @return: Returns the list of child objects that may carry textual data. 97 @rtype: list 98 """ 99 return self.source_list
100
101 - def get_note_child_list(self):
102 """ 103 Return the list of child secondary objects that may refer notes. 104 105 @return: Returns the list of child secondary child objects that may 106 refer notes. 107 @rtype: list 108 """ 109 return self.source_list
110
111 - def get_referenced_handles(self):
112 """ 113 Return the list of (classname, handle) tuples for all directly 114 referenced primary objects. 115 116 @return: List of (classname, handle) tuples for referenced objects. 117 @rtype: list 118 """ 119 ret = self.get_referenced_note_handles() 120 if self.ref: 121 ret += [('Person', self.ref)] 122 return ret
123
124 - def get_handle_referents(self):
125 """ 126 Return the list of child objects which may, directly or through 127 their children, reference primary objects.. 128 129 @return: Returns the list of objects refereincing primary objects. 130 @rtype: list 131 """ 132 return self.source_list
133
134 - def set_relation(self, rel):
135 """Set relation to a person.""" 136 self.rel = rel
137
138 - def get_relation(self):
139 """Return the relation to a person.""" 140 return self.rel
141