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 _cpool = DbConnectionPool() 20
21 - def close(self, conn):
22 self._cpool.put(conn)
23
24 - def connect(self):
25 """Load our database driver and connect to the database.""" 26 return self._cpool.get(backend=self.backend, 27 host=self.host, 28 port=self.port, 29 username=self.username, 30 password=self.password, 31 database=self.database)
32
33 - def cleanstring(self, value):
34 """Remove the trailing \x00 off the end of a string.""" 35 if type(value) in types.StringTypes: 36 return value.rstrip("\x00") 37 return value
38