Changed config keys

This commit is contained in:
Jedrzej Nowak 2015-11-18 14:25:37 +01:00
parent 83416678a3
commit 0dedcd867d
3 changed files with 17 additions and 18 deletions

View File

@ -2,10 +2,8 @@ dblayer: riak
redis:
host: localhost
port: '6379'
riak:
solar_db:
mode: riak
host: localhost
port: '8087'
protocol: pbc
sqlite:
backend: memory
location: ':memory:'

View File

@ -6,8 +6,7 @@ CWD = os.getcwd()
C = Bunch()
C.redis = Bunch(port='6379', host='10.0.0.2')
C.riak = Bunch(port='8087', host='10.0.0.2', protocol='pbc')
C.sqlite = Bunch(backend='memory', location=':memory:')
C.solar_db = Bunch(mode='riak', port='8087', host='10.0.0.2', protocol='pbc')
C.dblayer = 'riak'
@ -52,6 +51,7 @@ def from_configs():
config[path[-1]] = vals
_lookup_vals(_setter, C)
def from_env():
def _setter(config, path):
env_key = '_'.join(path).upper()

View File

@ -2,27 +2,28 @@ from solar.dblayer.model import ModelMeta
from solar.dblayer.riak_client import RiakClient
from solar.config import C
if C.dblayer == 'sqlite':
if C.solar_db.mode == 'sqlite':
from solar.dblayer.sql_client import SqlClient
if C.sqlite.backend == 'memory':
client = SqlClient(C.sqlite.location, threadlocals=False, autocommit=False)
elif C.sqlite.backend == 'file':
client = SqlClient(C.sqlite.location, threadlocals=True,
if C.solar_db.backend == 'memory':
client = SqlClient(C.solar_db.location, threadlocals=False, autocommit=False)
elif C.solar_db.backend == 'file':
client = SqlClient(C.solar_db.location, threadlocals=True,
autocommit=False, pragmas=(('journal_mode', 'WAL'),
('synchronous', 'NORMAL')))
else:
raise Exception('Unknown sqlite backend %s', C.sqlite.backend)
raise Exception('Unknown sqlite backend %s', C.solar_db.backend)
elif C.dblayer == 'riak':
elif C.solar_db.mode == 'riak':
from solar.dblayer.riak_client import RiakClient
if C.riak.protocol == 'pbc':
if C.solar_db.protocol == 'pbc':
client = RiakClient(
protocol=C.riak.protocol, host=C.riak.host, pb_port=C.riak.port)
elif C.riak.protocol == 'http':
protocol=C.solar_db.protocol, host=C.solar_db.host, pb_port=C.solar_db.port)
elif C.solar_db.protocol == 'http':
client = RiakClient(
protocol=C.riak.protocol, host=C.riak.host, http_port=C.riak.port)
protocol=C.solar_db.protocol, host=C.solar_db.host, http_port=C.solar_db.port)
else:
raise Exception('Unknown riak protocol %s', C.riak.protocol)
raise Exception('Unknown riak protocol %s', C.solar_db.protocol)
else:
raise Exception('Unknown dblayer backend %s', C.dblayer)