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

Source Code for Module gen.lib.ldsordbase

  1  # 
  2  # Gramps - a GTK+/GNOME based genealogy program 
  3  # 
  4  # Copyright (C) 2000-2006  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: ldsordbase.py 10103 2008-02-24 13:55:55Z acraphae $ 
 22   
 23  """ 
 24  LdsOrdBase class for GRAMPS. 
 25  """ 
 26   
 27  #------------------------------------------------------------------------- 
 28  # 
 29  # GRAMPS modules 
 30  # 
 31  #------------------------------------------------------------------------- 
 32  from gen.lib.ldsord import LdsOrd 
 33   
 34  #------------------------------------------------------------------------- 
 35  # 
 36  # LdsOrdBase classes 
 37  # 
 38  #------------------------------------------------------------------------- 
39 -class LdsOrdBase:
40 """ 41 Base class for lds_ord-aware objects. 42 """ 43
44 - def __init__(self, source=None):
45 """ 46 Initialize a LdsOrdBase. 47 48 If the source is not None, then object is initialized from values of 49 the source object. 50 51 @param source: Object used to initialize the new object 52 @type source: LdsOrdBase 53 """ 54 55 if source: 56 self.lds_ord_list = [ LdsOrd(lds_ord) \ 57 for lds_ord in source.lds_ord_list ] 58 else: 59 self.lds_ord_list = []
60
61 - def serialize(self):
62 """ 63 Convert the object to a serialized tuple of data. 64 """ 65 return [lds_ord.serialize() for lds_ord in self.lds_ord_list]
66
67 - def unserialize(self, data):
68 """ 69 Convert a serialized tuple of data to an object 70 """ 71 self.lds_ord_list = [LdsOrd().unserialize(item) for item in data]
72
73 - def add_lds_ord(self, lds_ord):
74 """ 75 Add the L{LdsOrd} instance to the object's list of lds_ordes. 76 77 @param lds_ord: L{LdsOrd} instance to add to the object's lds_ord list 78 @type lds_ord: list 79 """ 80 self.lds_ord_list.append(lds_ord)
81
82 - def remove_lds_ord(self, lds_ord):
83 """ 84 Remove the specified L{LdsOrd} instance from the lds_ord list. 85 86 If the instance does not exist in the list, the operation has no effect. 87 88 @param lds_ord: L{LdsOrd} instance to remove from the list 89 @type lds_ord: L{LdsOrd} 90 91 @return: True if the lds_ord was removed, False if it was not in the list. 92 @rtype: bool 93 """ 94 if lds_ord in self.lds_ord_list: 95 self.lds_ord_list.remove(lds_ord) 96 return True 97 else: 98 return False
99
100 - def get_lds_ord_list(self):
101 """ 102 Return the list of L{LdsOrd} instances associated with the object. 103 104 @return: Returns the list of L{LdsOrd} instances 105 @rtype: list 106 """ 107 return self.lds_ord_list
108
109 - def set_lds_ord_list(self, lds_ord_list):
110 """ 111 Assign the passed list to the object's list of L{LdsOrd} instances. 112 113 @param lds_ord_list: List of L{LdsOrd} instances to be associated 114 with the object 115 @type lds_ord_list: list 116 """ 117 self.lds_ord_list = lds_ord_list
118