Skip to content

Commit 0bc6560

Browse files
committed
refactor(data): move islolation_level to the data source root
Now the islolation_level configuration item will be at the data source root level Fixes: #447
1 parent 649f6ef commit 0bc6560

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

examples/testapp/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ def initialize(self):
6868
data_source_conf = {
6969
'connector': "sqlalchemy",
7070
'url': "mysql+pymysql://root@localhost:3306/test",
71+
# 'isolation_level': 'REPEATABLE READ',
7172
'pool': {
7273
'size': 10,
7374
'max_overflow': 10,
74-
# 'isolation_level': 'REPEATABLE READ',
7575
# 'pool_recycle': 400
7676
}
7777
}
@@ -85,7 +85,7 @@ def initialize(self):
8585
def install(self):
8686
""" Installing test database
8787
"""
88-
from firenado.util.sqlalchemy_util import Base
88+
from testapp.models import Base
8989
print('Installing Testapp App...')
9090
print('Creating App ...')
9191
engine = self.application.get_data_source(

examples/testapp/services.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,3 @@ def is_valid(self, username, password):
7272
if user.password == password_digest(password):
7373
return True
7474
return False
75-
76-

firenado/data.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ def configure(self, name, conf):
161161
# We will set the isolation level to READ UNCOMMITTED by default
162162
# to avoid the "cache" effect sqlalchemy has without this option.
163163
# Solution from: http://bit.ly/2bDq0Nv
164-
# TODO: Get the isolation level from data source conf
165164
engine_params = {
166165
'isolation_level': "READ UNCOMMITTED"
167166
}
@@ -176,15 +175,16 @@ def configure(self, name, conf):
176175
if conf['future']:
177176
engine_params['future'] = True
178177

178+
if "isolation_level" in conf:
179+
if conf['isolation_level']:
180+
engine_params['isolation_level'] = conf['isolation_level']
181+
179182
if "pool" in conf:
180183
if "class" in conf['pool']:
181184
engine_params['pool_class'] = conf['pool']['class']
182185
if isinstance(engine_params['pool_class'], str):
183186
engine_params['pool_class'] = config.get_from_string(
184187
engine_params['pool_class'])
185-
if "isolation_level" in conf['pool']:
186-
engine_params['isolation_level'] = conf['pool'][
187-
'isolation_level']
188188
if "max_overflow" in conf['pool']:
189189
engine_params['max_overflow'] = conf['pool']['max_overflow']
190190
if "pool_recycle" in conf['pool']:

0 commit comments

Comments
 (0)