Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/django/db/transaction.py
Commit message (Collapse)AuthorAgeFilesLines
* Fixed #24921 -- set_autocommit(False) + ORM queries.Aymeric Augustin2015-09-211-7/+0
| | | | | | | | | | | | | This commits lifts the restriction that the outermost atomic block must be declared with savepoint=False. This restriction was overly cautious. The logic that makes it safe not to create savepoints for inner blocks also applies to the outermost block when autocommit is disabled and a transaction is already active. This makes it possible to use the ORM after set_autocommit(False). Previously it didn't work because ORM write operations are protected with atomic(savepoint=False).
* Fixed #21803 -- Added support for post-commit callbacksAndreas Pelme2015-06-301-13/+9
| | | | | | | | | Made it possible to register and run callbacks after a database transaction is committed with the `transaction.on_commit()` function. This patch is heavily based on Carl Meyers django-transaction-hooks <https://django-transaction-hooks.readthedocs.org/>. Thanks to Aymeric Augustin, Carl Meyer, and Tim Graham for review and feedback.
* Sorted imports with isort; refs #23860.Tim Graham2015-02-061-2/+2
|
* Replaced set([foo, ...]) by {foo, ...} literals. Refs PR ↵Thomas Chaumeny2014-09-281-1/+1
| | | | | | 3282. Thanks Collin Anderson for the review.
* Factorize some code using ContextDecorator.Thomas Chaumeny2014-08-281-11/+2
|
* Fixed #23074 -- Avoided leaking savepoints in atomic.Aymeric Augustin2014-07-281-0/+6
| | | | Thanks Chow Loong Jin for the report and the initial patch.
* Improved a comment. Thanks intgr for the report.Aymeric Augustin2014-04-111-4/+4
|
* Increased robustness of 58161e4e. Refs #22291.Aymeric Augustin2014-04-101-2/+8
|
* Fixed #21202 -- Maintained atomicity when the server ↵Aymeric Augustin2014-04-101-3/+13
| | | | | | | | | | | disconnects. Thanks intgr for the report. This commit doesn't include a test because I don't know how to emulate a database disconnection in a cross-database compatible way. Also simplified a 'backends' test that was constrained by this problem.
* Fixed #21239 -- Maintained atomicity when closing the ↵Aymeric Augustin2014-04-101-3/+13
| | | | | | | connection. Refs #15802 -- Reverted #7c657b24 as BaseDatabaseWrapper.close() now has a proper "finally" clause that may need to preserve self.connection.
* Fixed #22291 -- Avoided shadowing deadlock exceptions on ↵Aymeric Augustin2014-03-231-1/+7
| | | | | | MySQL. Thanks err for the report.
* Removed legacy transaction management per the ↵Aymeric Augustin2014-03-211-259/+5
| | | | deprecation timeline.
* Fixed #21188 -- Introduced subclasses for ↵Claude Paroz2014-03-081-7/+8
| | | | | | | to-be-removed-in-django-XX warnings Thanks Anssi Kääriäinen for the idea and Simon Charette for the review.
* Fixed many typos in comments and docstrings.Rodolfo Carvalho2014-03-031-1/+1
| | | | Thanks Piotr Kasprzyk for help with the patch.
* Fixed #21288 -- Fixed E126 pep8 warningsAlasdair Nicol2013-10-211-2/+2
|
* Fixed #21134 -- Prevented queries in broken transactions.Aymeric Augustin2013-09-301-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Squashed commit of the following: commit 63ddb271a44df389b2c302e421fc17b7f0529755 Author: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Sun Sep 29 22:51:00 2013 +0200 Clarified interactions between atomic and exceptions. commit 2899ec299228217c876ba3aa4024e523a41c8504 Author: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Sun Sep 22 22:45:32 2013 +0200 Fixed TransactionManagementError in tests. Previous commit introduced an additional check to prevent running queries in transactions that will be rolled back, which triggered a few failures in the tests. In practice using transaction.atomic instead of the low-level savepoint APIs was enough to fix the problems. commit 4a639b059ea80aeb78f7f160a7d4b9f609b9c238 Author: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Tue Sep 24 22:24:17 2013 +0200 Allowed nesting constraint_checks_disabled inside atomic. Since MySQL handles transactions loosely, this isn't a problem. commit 2a4ab1cb6e83391ff7e25d08479e230ca564bfef Author: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Sat Sep 21 18:43:12 2013 +0200 Prevented running queries in transactions that will be rolled back. This avoids a counter-intuitive behavior in an edge case on databases with non-atomic transaction semantics. It prevents using savepoint_rollback() inside an atomic block without calling set_rollback(False) first, which is backwards-incompatible in tests. Refs #21134. commit 8e3db393853c7ac64a445b66e57f3620a3fde7b0 Author: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Sun Sep 22 22:14:17 2013 +0200 Replaced manual savepoints by atomic blocks. This ensures the rollback flag is handled consistently in internal APIs.
* Tested exc_type instead of exc_value in __exit__.Aymeric Augustin2013-09-041-7/+7
| | | | | | | | | exc_value might be None even though there's an exception, at least on Python 2.6. Thanks Thomas Chaumeny for the report. Fixed #21034. Forward-port of a8624b2 from 1.6.x.
* A large number of stylistic cleanups across django/db/Alex Gaynor2013-07-081-0/+26
|
* Introduced getters for connection.autocommit and ↵Aymeric Augustin2013-06-301-8/+4
| | | | | | | | | .needs_rollback. They ensure that the attributes aren't accessed in conditions where they don't contain a valid value. Fixed #20666.
* Advanced deprecation warnings for Django 1.7.Aymeric Augustin2013-06-291-7/+7
|
* Fixed #20571 -- Added an API to control ↵Aymeric Augustin2013-06-271-0/+20
| | | | | | | | | connection.needs_rollback. This is useful: - to force a rollback on the exit of an atomic block without having to raise and catch an exception; - to prevent a rollback after handling an exception manually.
* Changed API to disable ATOMIC_REQUESTS per view.Aymeric Augustin2013-05-191-0/+17
| | | | | | | A decorator is easier to apply to CBVs. Backwards compatibility isn't an issue here, except for people running on a recent clone of master. Fixed a few minor problems in the transactions docs while I was there.
* Fix typo in transaction.Atomic docstringMarti Raudsepp2013-04-031-1/+1
|
* Made atomic usable when autocommit is off.Aymeric Augustin2013-03-131-86/+69
| | | | | | | | | | | | | | | | Thanks Anssi for haggling until I implemented this. This change alleviates the need for atomic_if_autocommit. When autocommit is disabled for a database, atomic will simply create and release savepoints, and not commit anything. This honors the contract of not doing any transaction management. This change also makes the hack to allow using atomic within the legacy transaction management redundant. None of the above will work with SQLite, because of a flaw in the design of the sqlite3 library. This is a known limitation that cannot be lifted without unacceptable side effects eg. triggering arbitrary commits.
* Fixed #20028 -- Made atomic usable on callable instances.Aymeric Augustin2013-03-121-1/+2
| | | | Thanks Anssi for the report.
* Improved the API of set_autocommit.Aymeric Augustin2013-03-111-1/+1
|
* Added an option to disable the creation of savepoints in ↵Aymeric Augustin2013-03-111-29/+51
| | | | atomic.
* Re-ordered functions by deprecation status.Aymeric Augustin2013-03-111-17/+20
|
* Implemented atomic_if_autocommit.Aymeric Augustin2013-03-111-4/+22
| | | | It disables transaction management entirely when AUTOCOMMIT is False.
* Added some assertions to enforce the atomicity of atomic.Aymeric Augustin2013-03-111-2/+16
|
* Implemented an 'atomic' decorator and context manager.Aymeric Augustin2013-03-111-7/+150
| | | | | | Currently it only works in autocommit mode. Based on @xact by Christophe Pettus.
* Deprecated transaction.is_managed().Aymeric Augustin2013-03-111-7/+5
| | | | It's synchronized with the autocommit flag.
* Deprecated transaction.commit/rollback_unless_managed.Aymeric Augustin2013-03-111-8/+19
| | | | | | | | Since "unless managed" now means "if database-level autocommit", committing or rolling back doesn't have any effect. Restored transactional integrity in a few places that relied on automatically-started transactions with a transitory API.
* Added an API to control database-level autocommit.Aymeric Augustin2013-03-111-0/+12
|
* Made transaction.managed a no-op and deprecated it.Aymeric Augustin2013-03-111-12/+6
| | | | | | | | | | | | | | enter_transaction_management() was nearly always followed by managed(). In three places it wasn't, but they will all be refactored eventually. The "forced" keyword argument avoids introducing behavior changes until then. This is mostly backwards-compatible, except, of course, for managed itself. There's a minor difference in _enter_transaction_management: the top self.transaction_state now contains the new 'managed' state rather than the previous one. Django doesn't access self.transaction_state in _enter_transaction_management.
* Factored code and added a missing docstring.Aymeric Augustin2013-02-211-64/+36
|
* Fixed #19707 -- Reset transaction state after requestsAnssi Kääriäinen2013-02-101-0/+15
|
* Removed with_statement imports, useless in Python >= ↵Claude Paroz2012-03-301-1/+0
| | | | | | 2.6. Refs #17965. Thanks jonash for the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17828 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #16225 -- Removed unused imports. Many thanks to ↵Jannis Leidel2011-07-131-2/+0
| | | | | | Aymeric Augustin for the work on the patch and Alex for reviewing. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16539 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #15702 -- Corrected problem in test suite ↵Russell Keith-Magee2011-03-281-1/+1
| | | | | | introduced by Python 2.4 changes from r15927. Thanks to mk for the report and patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15937 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Move the Python 2.5 specific tests out of their own ↵Alex Gaynor2011-03-281-0/+1
| | | | | | special files now that 2.5 is the default. Also add __futre__ import where necessary. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15935 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Removed a bunch more Python 2.4 workarounds now that we ↵Adrian Holovaty2011-03-281-17/+4
| | | | | | don't support that version. Refs #15702 -- thanks to jonash for the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15927 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Changeset r15232 refactored transactions so that all ↵Russell Keith-Magee2011-02-121-80/+15
| | | | | | transaction state is maintained on the connection. This changeset continues that work, moving all transaction control to the connection, too. The transaction control functions in django.db.transaction are left as a generic way to easily apply a transaction control function based on a DB alias. Refs #9964. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15492 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Refactor all uses of thread locals to be more consistant ↵Alex Gaynor2011-01-171-56/+47
| | | | | | and sane. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15232 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #14550 -- fixed the behavior of commit_on_success ↵Alex Gaynor2010-10-241-9/+12
| | | | | | to exit the transaction properly. This was a bug introduced in [14288]. Thanks to Justin for the report and Florian Apolloner for help debugging. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14343 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #10771 -- added support for using the transaction ↵Alex Gaynor2010-10-191-60/+84
| | | | | | management functions as context managers in Python 2.5 and above. Thanks to Jacob for help with the docs. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14288 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #11509 -- Modified usage of "Web" to match our ↵Russell Keith-Magee2010-10-091-1/+1
| | | | | | style guide in various documentation, comments and code. Thanks to timo and Simon Meers for the work on the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14069 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #12164 -- Removed the Python 2.3 compatibility ↵Russell Keith-Magee2010-05-041-1/+1
| | | | | | imports and workarounds. Thanks to timo and claudep for the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@13094 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #11900 -- Corrected an edge case of transaction ↵Russell Keith-Magee2010-03-121-1/+5
| | | | | | handling in the commit_on_success decorator. Thanks to guettli for the report, and Gabriel Hurley for the initial test case. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12764 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #13055 -- Cleaned up the implementation of ↵Russell Keith-Magee2010-03-101-34/+46
| | | | | | transaction decorators to provide a consistent external facing API. Thanks to olb@nebkha.net for the report. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12752 bcc190cf-cafb-0310-a4f2-bffc1f526a37