Skip to content

Commit 384c2b6

Browse files
committed
lock SQLAlchemy>=1.3.0, <1.4.0: autobegin lead transaction func not working as excepted
1 parent bc0d3a9 commit 384c2b6

File tree

9 files changed

+137
-190
lines changed

9 files changed

+137
-190
lines changed

Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ name = "pypi"
66
[packages]
77
tox = "*"
88
ipython = "*"
9-
hobbit-core = {version = "==1.4.4", extras = ["hobbit", "hobbit_core"]}
109
cx-Oracle = "*"
10+
zipp = {extras = ["hobbit", "hobbit_core"], path = "."}
1111

1212
[dev-packages]
1313
sphinx = "==2.0.1"

Pipfile.lock

Lines changed: 129 additions & 180 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hobbit/static/bootstrap/rivendell/tests/__init__.py.jinja2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class BaseTest:
2424
pass
2525

2626
def teardown_method(self, method):
27-
for m in [m for m in db.Model._decl_class_registry.values()
27+
for m in [m for m in db.Model.registry._class_registry.values()
2828
if isinstance(m, model.DefaultMeta)]:
2929
db.session.query(m).delete()
3030
db.session.commit()

hobbit/static/bootstrap/shire/tests/__init__.py.jinja2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class BaseTest:
2424
pass
2525

2626
def teardown_method(self, method):
27-
for m in [m for m in db.Model._decl_class_registry.values()
27+
for m in [m for m in db.Model.registry._class_registry.values()
2828
if isinstance(m, model.DefaultMeta)]:
2929
db.session.query(m).delete()
3030
db.session.commit()

hobbit_core/db.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,10 +358,8 @@ def create(username, password):
358358
def wrapper(func):
359359
@wraps(func)
360360
def inner(*args, **kwargs):
361-
print(session.autocommit, "session.autocommit")
362361
if session.autocommit is True and nested is False:
363362
session.begin() # start a transaction
364-
365363
try:
366364
with session.begin_nested():
367365
resp = func(*args, **kwargs)

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def gen_data(data_root='static'):
3030

3131
setup(
3232
name='hobbit-core',
33-
version='1.4.4',
33+
version='2.0.0.rc1',
3434
python_requires='>=3.6, <4',
3535
description='Hobbit - A flask project generator.',
3636
long_description=long_description,
@@ -54,6 +54,7 @@ def gen_data(data_root='static'):
5454
'flask-marshmallow>=0.14.0, <1',
5555
'Flask-Migrate>=3.0.1, <4',
5656
'flask-shell-ipython>=0.4.1',
57+
'SQLAlchemy>=1.3.0, < 1.4.0',
5758
'Flask-SQLAlchemy>=2.5.1, <3',
5859
'marshmallow-enum>=1.5.1, <2',
5960
'marshmallow-sqlalchemy>=0.26.1, <3',

tests/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ def teardown_class(cls):
2222

2323
def teardown_method(self, method):
2424
with app.app_context():
25-
print(">>>>>>", [m for m in db.Model.registry._class_registry.values()])
26-
for m in [m for m in db.Model.registry._class_registry.values()
25+
for m in [m for m in db.Model._decl_class_registry.values()
26+
# db.Model.registry._class_registry.values()
2727
if isinstance(m, model.DefaultMeta) and
2828
getattr(m, '__bind_key__', None) != 'oracle']:
29-
print(m)
3029
db.session.query(m).delete()
3130
db.session.commit()
3231

tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def assert_session(app):
3030
conn = tdb.engine.connect()
3131
options = dict(bind=conn, binds={})
3232
sess = tdb.create_scoped_session(options=options)
33+
assert sess.autocommit is False
3334
yield sess
3435
sess.remove()
3536

tests/test_db.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ def create_user():
160160
session.commit()
161161

162162
msg = 'This transaction is closed'
163-
create_user()
164163
with pytest.raises(ResourceClosedError, match=msg):
165164
create_user()
166165
assert assert_session.query(User).all() == []

0 commit comments

Comments
 (0)