Skip to content

Commit

Permalink
refactor(data): move islolation_level to the data source root
Browse files Browse the repository at this point in the history
Now the islolation_level configuration item will be at the data
source root level

Fixes: #447
  • Loading branch information
piraz committed Apr 21, 2024
1 parent 649f6ef commit 0bc6560
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions examples/testapp/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ def initialize(self):
data_source_conf = {
'connector': "sqlalchemy",
'url': "mysql+pymysql://root@localhost:3306/test",
# 'isolation_level': 'REPEATABLE READ',
'pool': {
'size': 10,
'max_overflow': 10,
# 'isolation_level': 'REPEATABLE READ',
# 'pool_recycle': 400
}
}
Expand All @@ -85,7 +85,7 @@ def initialize(self):
def install(self):
""" Installing test database
"""
from firenado.util.sqlalchemy_util import Base
from testapp.models import Base
print('Installing Testapp App...')
print('Creating App ...')
engine = self.application.get_data_source(
Expand Down
2 changes: 0 additions & 2 deletions examples/testapp/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,3 @@ def is_valid(self, username, password):
if user.password == password_digest(password):
return True
return False


8 changes: 4 additions & 4 deletions firenado/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ def configure(self, name, conf):
# We will set the isolation level to READ UNCOMMITTED by default
# to avoid the "cache" effect sqlalchemy has without this option.
# Solution from: http://bit.ly/2bDq0Nv
# TODO: Get the isolation level from data source conf
engine_params = {
'isolation_level': "READ UNCOMMITTED"
}
Expand All @@ -176,15 +175,16 @@ def configure(self, name, conf):
if conf['future']:
engine_params['future'] = True

if "isolation_level" in conf:
if conf['isolation_level']:
engine_params['isolation_level'] = conf['isolation_level']

if "pool" in conf:
if "class" in conf['pool']:
engine_params['pool_class'] = conf['pool']['class']
if isinstance(engine_params['pool_class'], str):
engine_params['pool_class'] = config.get_from_string(
engine_params['pool_class'])
if "isolation_level" in conf['pool']:
engine_params['isolation_level'] = conf['pool'][
'isolation_level']
if "max_overflow" in conf['pool']:
engine_params['max_overflow'] = conf['pool']['max_overflow']
if "pool_recycle" in conf['pool']:
Expand Down

0 comments on commit 0bc6560

Please sign in to comment.