##// END OF EJS Templates
fixed ldap settings creation, we need to fill in some bool defaults properly to make it work fine
marcink -
r1138:9c45e114 beta
parent child Browse files
Show More
@@ -60,38 +60,18 b' class DbManage(object):'
60 60 init_model(engine)
61 61 self.sa = meta.Session()
62 62
63 def check_for_db(self, override):
64 db_path = jn(self.root, self.dbname)
65 if self.dburi.startswith('sqlite'):
66 log.info('checking for existing db in %s', db_path)
67 if os.path.isfile(db_path):
68
69 self.db_exists = True
70 if not override:
71 raise Exception('database already exists')
72 return 'sqlite'
73 if self.dburi.startswith('postgresql'):
74 self.db_exists = True
75 return 'postgresql'
76
77
78 63 def create_tables(self, override=False):
79 64 """Create a auth database
80 65 """
81 66
82 db_type = self.check_for_db(override)
83 if self.db_exists:
84 log.info("database exist and it's going to be destroyed")
67 log.info("Any existing database is going to be destroyed")
85 68 if self.tests:
86 69 destroy = True
87 70 else:
88 71 destroy = ask_ok('Are you sure to destroy old database ? [y/n]')
89 72 if not destroy:
90 73 sys.exit()
91 if self.db_exists and destroy:
92 if db_type == 'sqlite':
93 os.remove(jn(self.root, self.dbname))
94 if db_type == 'postgresql':
74 if destroy:
95 75 meta.Base.metadata.drop_all()
96 76
97 77 checkfirst = not override
@@ -335,13 +315,16 b' class DbManage(object):'
335 315 """Creates ldap settings"""
336 316
337 317 try:
338 for k in ['ldap_active', 'ldap_host', 'ldap_port', 'ldap_ldaps',
339 'ldap_tls_reqcert', 'ldap_dn_user', 'ldap_dn_pass',
340 'ldap_base_dn', 'ldap_filter', 'ldap_search_scope',
341 'ldap_attr_login', 'ldap_attr_firstname', 'ldap_attr_lastname',
342 'ldap_attr_email']:
318 for k, v in [('ldap_active', 'false'), ('ldap_host', ''),
319 ('ldap_port', '389'), ('ldap_ldaps', 'false'),
320 ('ldap_tls_reqcert', ''), ('ldap_dn_user', ''),
321 ('ldap_dn_pass', ''), ('ldap_base_dn', ''),
322 ('ldap_filter', ''), ('ldap_search_scope', ''),
323 ('ldap_attr_login', ''), ('ldap_attr_firstname', ''),
324 ('ldap_attr_lastname', ''), ('ldap_attr_email', '')]:
343 325
344 setting = RhodeCodeSettings(k, '')
326
327 setting = RhodeCodeSettings(k, v)
345 328 self.sa.add(setting)
346 329 self.sa.commit()
347 330 except:
General Comments 0
You need to be logged in to leave comments. Login now