[Python-modules-commits] [python-social-auth] 82/131: Fix for flask/sqlachemy: commit on save (but not when using Pyramid)
Wolfgang Borgert
debacle at moszumanska.debian.org
Sat Dec 24 15:17:05 UTC 2016
This is an automated email from the git hooks/post-receive script.
debacle pushed a commit to tag v0.2.20
in repository python-social-auth.
commit 88dce26f19e3ded1950bf1f00720ac1498778f7a
Author: Andrei Oghina <aoghina at gmail.com>
Date: Sun Jul 17 20:11:00 2016 +0200
Fix for flask/sqlachemy: commit on save (but not when using Pyramid)
---
social/apps/pyramid_app/models.py | 2 ++
social/storage/sqlalchemy_orm.py | 8 +++++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/social/apps/pyramid_app/models.py b/social/apps/pyramid_app/models.py
index 2d70e06..5752f3f 100644
--- a/social/apps/pyramid_app/models.py
+++ b/social/apps/pyramid_app/models.py
@@ -24,6 +24,8 @@ def init_social(config, Base, session):
app_session = session
class _AppSession(object):
+ COMMIT_SESSION = False
+
@classmethod
def _session(cls):
return app_session
diff --git a/social/storage/sqlalchemy_orm.py b/social/storage/sqlalchemy_orm.py
index 621bf4c..e48ef64 100644
--- a/social/storage/sqlalchemy_orm.py
+++ b/social/storage/sqlalchemy_orm.py
@@ -28,6 +28,8 @@ class JSONType(PickleType):
class SQLAlchemyMixin(object):
+ COMMIT_SESSION = True
+
@classmethod
def _session(cls):
raise NotImplementedError('Implement in subclass')
@@ -43,7 +45,11 @@ class SQLAlchemyMixin(object):
@classmethod
def _save_instance(cls, instance):
cls._session().add(instance)
- cls._flush()
+ if cls.COMMIT_SESSION:
+ cls._session().commit()
+ cls._session().flush()
+ else:
+ cls._flush()
return instance
@classmethod
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-social-auth.git
More information about the Python-modules-commits
mailing list