Merge "Remove use of Session.begin.subtransactions flag"
This commit is contained in:
commit
f756a19567
@ -34,18 +34,8 @@ class ModelBase(object):
|
|||||||
|
|
||||||
def save(self, session):
|
def save(self, session):
|
||||||
"""Save this object."""
|
"""Save this object."""
|
||||||
|
session.add(self)
|
||||||
# NOTE(boris-42): This part of code should be look like:
|
session.flush()
|
||||||
# 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()
|
|
||||||
|
|
||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
setattr(self, key, value)
|
setattr(self, key, value)
|
||||||
|
@ -45,11 +45,6 @@ class WarningsFixture(fixtures.Fixture):
|
|||||||
message=r'The Session.autocommit parameter is deprecated .*',
|
message=r'The Session.autocommit parameter is deprecated .*',
|
||||||
category=sqla_exc.SADeprecationWarning)
|
category=sqla_exc.SADeprecationWarning)
|
||||||
|
|
||||||
warnings.filterwarnings(
|
|
||||||
'once',
|
|
||||||
message=r'The Session.begin.subtransactions flag is deprecated .*',
|
|
||||||
category=sqla_exc.SADeprecationWarning)
|
|
||||||
|
|
||||||
warnings.filterwarnings(
|
warnings.filterwarnings(
|
||||||
'once',
|
'once',
|
||||||
message=r'Calling \.begin\(\) when a transaction is already .*',
|
message=r'Calling \.begin\(\) when a transaction is already .*',
|
||||||
|
Loading…
Reference in New Issue
Block a user