Commit cd5f697a authored by Stephen Finucane's avatar Stephen Finucane
Browse files

Remove use of Session.begin.subtransactions flag



Resolve the following RemovedIn20Warning warning:

  The Session.begin.subtransactions flag is deprecated and will be
  removed in SQLAlchemy version 2.0.  See the documentation at
  session_subtransactions for background on a compatible alternative
  pattern.

Change-Id: Ib2537bae77861ee60d17a48a72c57b88e043553e
Signed-off-by: default avatarStephen Finucane <stephenfin@redhat.com>
parent b3a56b35
......@@ -34,18 +34,8 @@ class ModelBase(object):
def save(self, session):
"""Save this object."""
# NOTE(boris-42): This part of code should be look like:
# session.add(self)
# session.flush()
# But there is a bug in sqlalchemy and eventlet that
# raises NoneType exception if there is no running
# transaction and rollback is called. As long as
# sqlalchemy has this bug we have to create transaction
# explicitly.
with session.begin(subtransactions=True):
session.add(self)
session.flush()
session.add(self)
session.flush()
def __setitem__(self, key, value):
setattr(self, key, value)
......
......@@ -42,11 +42,6 @@ class WarningsFixture(fixtures.Fixture):
message=r'The Session.autocommit parameter is deprecated .*',
category=sqla_exc.SADeprecationWarning)
warnings.filterwarnings(
'once',
message=r'The Session.begin.subtransactions flag is deprecated .*',
category=sqla_exc.SADeprecationWarning)
warnings.filterwarnings(
'once',
message=r'Calling \.begin\(\) when a transaction is already .*',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment