Package gofer :: Package agent :: Module whiteboard
[hide private]
[frames] | no frames]

Source Code for Module gofer.agent.whiteboard

 1  # 
 2  # Copyright (c) 2011 Red Hat, Inc. 
 3  # 
 4  # This software is licensed to you under the GNU Lesser General Public 
 5  # License as published by the Free Software Foundation; either version 
 6  # 2 of the License (LGPLv2) or (at your option) any later version. 
 7  # There is NO WARRANTY for this software, express or implied, 
 8  # including the implied warranties of MERCHANTABILITY, 
 9  # NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should 
10  # have received a copy of LGPLv2 along with this software; if not, see 
11  # http://www.gnu.org/licenses/old-licenses/lgpl-2.0.txt. 
12  # 
13  # Jeff Ortel <jortel@redhat.com> 
14  # 
15   
16  from threading import RLock 
17  from gofer import Singleton, synchronized 
18 19 20 -class Whiteboard:
21 """ 22 Provides a dict-like object used to publish 23 information to other plugins. 24 """ 25 26 __metaclass__ = Singleton 27
28 - def __init__(self):
29 self.__dict = {} 30 self.__mutex = RLock()
31 32 @synchronized
33 - def get(self, name, default=None):
34 return self.__dict.get(name, default)
35 36 @synchronized
37 - def update(self, d):
38 self.__dict.update(d)
39 40 @synchronized
41 - def __getitem__(self, name):
42 return self.__dict[name]
43 44 @synchronized
45 - def __setitem__(self, name, value):
46 self.__dict[name] = value
47 48 @synchronized
49 - def __repr__(self):
50 return repr(self.__dict)
51 52 @synchronized
53 - def __str__(self):
54 return str(self.__dict)
55