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

Source Code for Module gen.lib.refbase

 1  # 
 2  # Gramps - a GTK+/GNOME based genealogy program 
 3  # 
 4  # Copyright (C) 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: refbase.py 10103 2008-02-24 13:55:55Z acraphae $ 
22   
23  """ 
24  Base Reference class for GRAMPS. 
25  """ 
26   
27  #------------------------------------------------------------------------- 
28  # 
29  # RefBase class 
30  # 
31  #------------------------------------------------------------------------- 
32 -class RefBase:
33 """ 34 Base reference class to manage references to other objects. 35 36 Any *Ref class should derive from this class. 37 """ 38
39 - def __init__(self, source=None):
40 if source: 41 self.ref = source.ref 42 else: 43 self.ref = None
44
45 - def serialize(self):
46 """ 47 Convert the object to a serialized tuple of data. 48 """ 49 return self.ref
50
51 - def unserialize(self, data):
52 """ 53 Convert a serialized tuple of data to an object. 54 """ 55 self.ref = str(data) 56 return self
57
58 - def get_referenced_handles(self):
59 """ 60 Returns the list of (classname, handle) tuples for all directly 61 referenced primary objects. 62 63 @return: Returns the list of (classname, handle) tuples for referenced 64 objects. 65 @rtype: list 66 """ 67 assert False, "Must be overridden in the derived class"
68
69 - def set_reference_handle(self, val):
70 self.ref = val
71
72 - def get_reference_handle(self):
73 return self.ref
74