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

Source Code for Module gen.lib.reporef

  1  # 
  2  # Gramps - a GTK+/GNOME based genealogy program 
  3  # 
  4  # Copyright (C) 2000-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: reporef.py 10103 2008-02-24 13:55:55Z acraphae $ 
 22   
 23  """ 
 24  Repository Reference class for GRAMPS 
 25  """ 
 26   
 27  #------------------------------------------------------------------------- 
 28  # 
 29  # Python modules 
 30  # 
 31  #------------------------------------------------------------------------- 
 32  from types import InstanceType 
 33   
 34  #------------------------------------------------------------------------- 
 35  # 
 36  # GRAMPS modules 
 37  # 
 38  #------------------------------------------------------------------------- 
 39  from gen.lib.secondaryobj import SecondaryObject 
 40  from gen.lib.privacybase import PrivacyBase 
 41  from gen.lib.notebase import NoteBase 
 42  from gen.lib.refbase import RefBase 
 43  from gen.lib.srcmediatype import SourceMediaType 
 44   
 45  #------------------------------------------------------------------------- 
 46  # 
 47  # Repository Reference for Sources 
 48  # 
 49  #------------------------------------------------------------------------- 
50 -class RepoRef(SecondaryObject, PrivacyBase, NoteBase, RefBase):
51 """ 52 Repository reference class. 53 """ 54
55 - def __init__(self, source=None):
56 PrivacyBase.__init__(self, source) 57 NoteBase.__init__(self, source) 58 RefBase.__init__(self, source) 59 if source: 60 self.call_number = source.call_number 61 self.media_type = source.media_type 62 else: 63 self.call_number = "" 64 self.media_type = SourceMediaType()
65
66 - def serialize(self):
67 """ 68 Convert the object to a serialized tuple of data. 69 """ 70 return ( 71 NoteBase.serialize(self), 72 RefBase.serialize(self), 73 self.call_number, self.media_type.serialize(), 74 PrivacyBase.serialize(self), 75 )
76
77 - def unserialize(self, data):
78 """ 79 Convert a serialized tuple of data to an object. 80 """ 81 (note_list, ref, self.call_number, media_type, privacy) = data 82 self.media_type = InstanceType(SourceMediaType) 83 self.media_type.unserialize(media_type) 84 PrivacyBase.unserialize(self, privacy) 85 NoteBase.unserialize(self, note_list) 86 RefBase.unserialize(self, ref) 87 return self
88
89 - def get_text_data_list(self):
90 """ 91 Return the list of all textual attributes of the object. 92 93 @return: Returns the list of all textual attributes of the object. 94 @rtype: list 95 """ 96 return [self.call_number, str(self.media_type)]
97
98 - def get_referenced_handles(self):
99 """ 100 Return the list of (classname, handle) tuples for all directly 101 referenced primary objects. 102 103 @return: List of (classname, handle) tuples for referenced objects. 104 @rtype: list 105 """ 106 ret = self.get_referenced_note_handles() 107 if self.ref: 108 ret += [('Repository', self.ref)] 109 return ret
110
111 - def set_call_number(self, number):
112 self.call_number = number
113
114 - def get_call_number(self):
115 return self.call_number
116
117 - def get_media_type(self):
118 return self.media_type
119
120 - def set_media_type(self, media_type):
121 self.media_type.set(media_type)
122