Project

General

Profile

« Previous | Next » 

Revision 8a3f16cd

Added by Frédéric Péters almost 13 years ago

wcsinstd: configure sql access

View differences:

wcsinst/wcsinstd/deploy.py
import cPickle
import os
import zipfile
import subprocess
from urlparse import urlparse
from cStringIO import StringIO
......
wcs_cfg = cPickle.load(file(os.path.join(self.collectivity_install_dir, 'config.pck')))
else:
wcs_cfg = {}
# TODO: there are some settings to change in wcs_cfg
# (like the name of the database)
has_sql = self.make_sql_config(wcs_cfg)
self.make_sso_config(wcs_cfg)
self.make_site_options()
cPickle.dump(wcs_cfg, file(config_file, 'w'))
if has_sql:
self.make_sql_tables(wcs_cfg)
self.make_apache_vhost()
self.reload_apache()
def make_sql_config(self, wcs_cfg):
if not wcs_cfg.get('postgresql'):
# this is not a site configured to use SQL
return False
database_name = wcs_cfg['postgresql'].get('database', 'wcs')
domain_table_name = self.domain.replace('-', '_').replace('.', '_')
if '_' in database_name:
database_name = '%s_%s' % (database_name.split('_')[0], domain_table)
else:
database_name = '%s_%s' % (database_name, domain_table)
try:
pgconn = psycopg2.connect(**wcs_cfg['postgresql'])
except psycopg2.Error:
# XXX: log
raise
cur = pgconn.cursor()
cur.execute('''CREATE DATABASE %s''' % database_name)
pgconn.commit()
cur.close()
wcs_cfg['postgresql']['database'] = database_name
return True
def make_sql_tables(self, wcs_cfg):
params = []
for param in ('dbname', 'user', 'password', 'host', 'port'):
if wcs_cfg.get('postgresql').get(param):
params.append(param)
params.append(wcs_cfg.get('postgresql').get(param))
os.system('wcsctl convertsql %s %s' % (' '.join(params), self.domain))
def make_sso_config(self, wcs_cfg):
has_idff = False
has_saml2 = False

Also available in: Unified diff