[Python-modules-commits] [python-social-auth] 220/322: Conditional import on transaction, update docs to mention it. Fixes #572
Wolfgang Borgert
debacle at moszumanska.debian.org
Sat Dec 24 15:13:11 UTC 2016
This is an automated email from the git hooks/post-receive script.
debacle pushed a commit to tag v0.2.10
in repository python-social-auth.
commit 08996453dd00524789557a56cac852bfcae45a7c
Author: Matías Aguirre <matiasaguirre at gmail.com>
Date: Fri Apr 3 23:16:35 2015 -0300
Conditional import on transaction, update docs to mention it. Fixes #572
---
docs/storage.rst | 9 ++++++---
social/storage/sqlalchemy_orm.py | 12 +++++++++---
2 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/docs/storage.rst b/docs/storage.rst
index 59b10ad..80e177d 100644
--- a/docs/storage.rst
+++ b/docs/storage.rst
@@ -170,12 +170,14 @@ models references and implement the needed method::
raise NotImplementedError('Implement in subclass')
-Sqlalchemy and Django mixins
+SQLAlchemy and Django mixins
----------------------------
-Currently there are partial implementations of mixins for `Sqlalchemy ORM`_ and
+Currently there are partial implementations of mixins for `SQLAlchemy ORM`_ and
`Django ORM`_ with common code used later on current implemented applications.
+**When using `SQLAlchemy ORM`_ and ``ZopeTransactionExtension``, it's
+recommended to use the transaction_ application to handle them.**
Models Examples
---------------
@@ -188,10 +190,11 @@ App`_, and `Webpy App`_ for examples of implementations.
.. _NonceMixin: https://github.com/omab/python-social-auth/blob/master/social/storage/base.py#L149
.. _AssociationMixin: https://github.com/omab/python-social-auth/blob/master/social/storage/base.py#L161
.. _BaseStorage: https://github.com/omab/python-social-auth/blob/master/social/storage/base.py#L201
-.. _Sqlalchemy ORM: https://github.com/omab/python-social-auth/blob/master/social/storage/sqlalchemy_orm.py
+.. _SQLAlchemy ORM: https://github.com/omab/python-social-auth/blob/master/social/storage/sqlalchemy_orm.py
.. _Django ORM: https://github.com/omab/python-social-auth/blob/master/social/storage/django_orm.py
.. _Django App: https://github.com/omab/python-social-auth/blob/master/social/apps/django_app/default/models.py
.. _Flask App: https://github.com/omab/python-social-auth/blob/master/social/apps/flask_app/models.py
.. _Pyramid App: https://github.com/omab/python-social-auth/blob/master/social/apps/pyramid_app/models.py
.. _Webpy App: https://github.com/omab/python-social-auth/blob/master/social/apps/webpy_app/models.py
.. _pipeline docs: pipeline.html#email-validation
+.. _transaction: https://pypi.python.org/pypi/transaction
diff --git a/social/storage/sqlalchemy_orm.py b/social/storage/sqlalchemy_orm.py
index 978d2b9..71010f7 100644
--- a/social/storage/sqlalchemy_orm.py
+++ b/social/storage/sqlalchemy_orm.py
@@ -3,7 +3,10 @@ import base64
import six
import json
-import transaction
+try:
+ import transaction
+except ImportError:
+ transaction = None
from sqlalchemy import Column, Integer, String
from sqlalchemy.exc import IntegrityError
@@ -47,8 +50,11 @@ class SQLAlchemyMixin(object):
try:
cls._session().flush()
except AssertionError:
- with transaction.manager as manager:
- manager.commit()
+ if transaction:
+ with transaction.manager as manager:
+ manager.commit()
+ else:
+ cls._session().commit()
def save(self):
self._save_instance(self)
--
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