6
from tools.misc import UpdateableStr, UpdateableDict
9
_connection_arch = UpdateableStr()
11
def _test_connection(self,cr,uid,part,context={}):
12
lines=pooler.get_pool(cr.dbname).get('olap.fact.database').browse(cr, uid, part['id'],context)
15
db_name = lines.db_name
17
password = lines.db_password
19
return_str = "Connection Successful"
21
if type == 'postgres':
22
tdb = psycopg2.connect('host=%s port=%s dbname=%s user=%s password=%s' % (host, port, db_name, user, password))
26
tdb = MySQLdb.connect(host = host,port = port, db = db_name, user = user, passwd = password)
29
elif type == 'oracle':
31
tdb = cx_Oracle.connect(user, password, host)
34
return_str = e.message
36
_arch = ['''<?xml version="1.0"?>''', '''<form string="Connection Status">''']
37
_arch.append('''<label string='%s' />''' % (return_str))
38
_arch.append('''</form>''')
39
_connection_arch.string = '\n'.join(_arch)
45
class wizard_test_connection(wizard.interface):
48
'actions': [_test_connection],
49
'result': {'type':'form', 'arch': _connection_arch, 'fields':{}, 'state':[('end','Ok')]}
52
wizard_test_connection('olap.fact.database.test_connection')