Package ZenEvents :: Module DbAccessBase
[hide private]
[frames] | no frames]

Source Code for Module ZenEvents.DbAccessBase

 1  ########################################################################### 
 2  # 
 3  # This program is part of Zenoss Core, an open source monitoring platform. 
 4  # Copyright (C) 2007, Zenoss Inc. 
 5  # 
 6  # This program is free software; you can redistribute it and/or modify it 
 7  # under the terms of the GNU General Public License version 2 as published by 
 8  # the Free Software Foundation. 
 9  # 
10  # For complete information please visit: http://www.zenoss.com/oss/ 
11  # 
12  ########################################################################### 
13  import types 
14   
15  from DbConnectionPool import DbConnectionPool 
16   
17 -class DbAccessBase(object):
18 19 # if we make this object persistent, we do not want to save make 20 # connections to the other database persistent. 21 22 _v_cpool = DbConnectionPool() 23
24 - def close(self, conn):
25 self._v_cpool.put(conn)
26
27 - def connect(self):
28 """Load our database driver and connect to the database.""" 29 return self._v_cpool.get(host=self.host, 30 port=self.port, 31 username=self.username, 32 password=self.password, 33 database=self.database)
34
35 - def cleanstring(self, value):
36 """Remove the trailing \x00 off the end of a string.""" 37 if type(value) in types.StringTypes: 38 return value.rstrip("\x00") 39 return value
40