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

Source Code for Module gen.lib.privacybase

 1  # 
 2  # Gramps - a GTK+/GNOME based genealogy program 
 3  # 
 4  # Copyright (C) 2000-2005  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: privacybase.py 10103 2008-02-24 13:55:55Z acraphae $ 
22   
23  """ 
24  PrivacyBase Object class for GRAMPS. 
25  """ 
26   
27  #------------------------------------------------------------------------- 
28  # 
29  # PrivacyBase Object 
30  # 
31  #------------------------------------------------------------------------- 
32 -class PrivacyBase:
33 """ 34 Base class for privacy-aware objects. 35 """ 36
37 - def __init__(self, source=None):
38 """ 39 Initialize a PrivacyBase. 40 41 If the source is not None, then object is initialized from values of 42 the source object. 43 44 @param source: Object used to initialize the new object 45 @type source: PrivacyBase 46 """ 47 48 if source: 49 self.private = source.private 50 else: 51 self.private = False
52
53 - def serialize(self):
54 """ 55 Convert the object to a serialized tuple of data. 56 """ 57 return self.private
58
59 - def unserialize(self, data):
60 """ 61 Convert a serialized tuple of data to an object. 62 """ 63 self.private = data 64 return self
65
66 - def set_privacy(self, val):
67 """ 68 Set or clears the privacy flag of the data. 69 70 @param val: value to assign to the privacy flag. True indicates that 71 the record is private, False indicates that it is public. 72 @type val: bool 73 """ 74 self.private = val
75
76 - def get_privacy(self):
77 """ 78 Return the privacy level of the data. 79 80 @returns: True indicates that the record is private 81 @rtype: bool 82 """ 83 return self.private
84