##// 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,39 +60,19 b' class DbManage(object):'
60 init_model(engine)
60 init_model(engine)
61 self.sa = meta.Session()
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 def create_tables(self, override=False):
63 def create_tables(self, override=False):
79 """Create a auth database
64 """Create a auth database
80 """
65 """
81
66
82 db_type = self.check_for_db(override)
67 log.info("Any existing database is going to be destroyed")
83 if self.db_exists:
68 if self.tests:
84 log.info("database exist and it's going to be destroyed")
69 destroy = True
85 if self.tests:
70 else:
86 destroy = True
71 destroy = ask_ok('Are you sure to destroy old database ? [y/n]')
87 else:
72 if not destroy:
88 destroy = ask_ok('Are you sure to destroy old database ? [y/n]')
73 sys.exit()
89 if not destroy:
74 if destroy:
90 sys.exit()
75 meta.Base.metadata.drop_all()
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':
95 meta.Base.metadata.drop_all()
96
76
97 checkfirst = not override
77 checkfirst = not override
98 meta.Base.metadata.create_all(checkfirst=checkfirst)
78 meta.Base.metadata.create_all(checkfirst=checkfirst)
@@ -335,13 +315,16 b' class DbManage(object):'
335 """Creates ldap settings"""
315 """Creates ldap settings"""
336
316
337 try:
317 try:
338 for k in ['ldap_active', 'ldap_host', 'ldap_port', 'ldap_ldaps',
318 for k, v in [('ldap_active', 'false'), ('ldap_host', ''),
339 'ldap_tls_reqcert', 'ldap_dn_user', 'ldap_dn_pass',
319 ('ldap_port', '389'), ('ldap_ldaps', 'false'),
340 'ldap_base_dn', 'ldap_filter', 'ldap_search_scope',
320 ('ldap_tls_reqcert', ''), ('ldap_dn_user', ''),
341 'ldap_attr_login', 'ldap_attr_firstname', 'ldap_attr_lastname',
321 ('ldap_dn_pass', ''), ('ldap_base_dn', ''),
342 'ldap_attr_email']:
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 self.sa.add(setting)
328 self.sa.add(setting)
346 self.sa.commit()
329 self.sa.commit()
347 except:
330 except:
General Comments 0
You need to be logged in to leave comments. Login now