Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
3bdc7a6a
Kaydet (Commit)
3bdc7a6a
authored
Mar 04, 2013
tarafından
Aymeric Augustin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Deprecated transaction.is_managed().
It's synchronized with the autocommit flag.
üst
ba5138b1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
23 additions
and
30 deletions
+23
-30
__init__.py
django/db/backends/__init__.py
+12
-18
deletion.py
django/db/models/deletion.py
+1
-1
query.py
django/db/models/query.py
+2
-2
transaction.py
django/db/transaction.py
+5
-7
transaction.py
django/middleware/transaction.py
+1
-1
deprecation.txt
docs/internals/deprecation.txt
+1
-0
tests.py
tests/middleware/tests.py
+1
-1
No files found.
django/db/backends/__init__.py
Dosyayı görüntüle @
3bdc7a6a
...
...
@@ -256,11 +256,12 @@ class BaseDatabaseWrapper(object):
"""
self
.
transaction_state
.
append
(
managed
)
if
managed
and
self
.
autocommit
:
self
.
set_autocommit
(
False
)
if
not
managed
and
self
.
is_dirty
()
and
not
forced
:
self
.
commit
()
self
.
set_clean
()
if
managed
==
self
.
autocommit
:
self
.
set_autocommit
(
not
managed
)
def
leave_transaction_management
(
self
):
"""
...
...
@@ -274,19 +275,20 @@ class BaseDatabaseWrapper(object):
raise
TransactionManagementError
(
"This code isn't under transaction management"
)
# That's the next state -- we already left the previous state behind.
managed
=
self
.
is_managed
()
if
self
.
transaction_state
:
managed
=
self
.
transaction_state
[
-
1
]
else
:
managed
=
settings
.
TRANSACTIONS_MANAGED
if
self
.
_dirty
:
self
.
rollback
()
if
not
managed
and
not
self
.
autocommit
:
self
.
set_autocommit
(
True
)
if
managed
==
self
.
autocommit
:
self
.
set_autocommit
(
not
managed
)
raise
TransactionManagementError
(
"Transaction managed block ended with pending COMMIT/ROLLBACK"
)
if
not
managed
and
not
self
.
autocommit
:
self
.
set_autocommit
(
True
)
if
managed
==
self
.
autocommit
:
self
.
set_autocommit
(
not
managed
)
def
set_autocommit
(
self
,
autocommit
=
True
):
"""
...
...
@@ -331,14 +333,6 @@ class BaseDatabaseWrapper(object):
self
.
_dirty
=
False
self
.
clean_savepoints
()
def
is_managed
(
self
):
"""
Checks whether the transaction manager is in manual or in auto state.
"""
if
self
.
transaction_state
:
return
self
.
transaction_state
[
-
1
]
return
settings
.
TRANSACTIONS_MANAGED
##### Foreign key constraints checks handling #####
@contextmanager
...
...
django/db/models/deletion.py
Dosyayı görüntüle @
3bdc7a6a
...
...
@@ -53,7 +53,7 @@ def DO_NOTHING(collector, field, sub_objs, using):
def
force_managed
(
func
):
@wraps
(
func
)
def
decorated
(
self
,
*
args
,
**
kwargs
):
if
not
transaction
.
is_managed
(
using
=
self
.
using
):
if
transaction
.
get_autocommit
(
using
=
self
.
using
):
transaction
.
enter_transaction_management
(
using
=
self
.
using
,
forced
=
True
)
forced_managed
=
True
else
:
...
...
django/db/models/query.py
Dosyayı görüntüle @
3bdc7a6a
...
...
@@ -442,7 +442,7 @@ class QuerySet(object):
self
.
_for_write
=
True
connection
=
connections
[
self
.
db
]
fields
=
self
.
model
.
_meta
.
local_fields
if
not
transaction
.
is_managed
(
using
=
self
.
db
):
if
transaction
.
get_autocommit
(
using
=
self
.
db
):
transaction
.
enter_transaction_management
(
using
=
self
.
db
,
forced
=
True
)
forced_managed
=
True
else
:
...
...
@@ -579,7 +579,7 @@ class QuerySet(object):
self
.
_for_write
=
True
query
=
self
.
query
.
clone
(
sql
.
UpdateQuery
)
query
.
add_update_values
(
kwargs
)
if
not
transaction
.
is_managed
(
using
=
self
.
db
):
if
transaction
.
get_autocommit
(
using
=
self
.
db
):
transaction
.
enter_transaction_management
(
using
=
self
.
db
,
forced
=
True
)
forced_managed
=
True
else
:
...
...
django/db/transaction.py
Dosyayı görüntüle @
3bdc7a6a
...
...
@@ -113,10 +113,8 @@ def clean_savepoints(using=None):
get_connection
(
using
)
.
clean_savepoints
()
def
is_managed
(
using
=
None
):
"""
Checks whether the transaction manager is in manual or in auto state.
"""
return
get_connection
(
using
)
.
is_managed
()
warnings
.
warn
(
"'is_managed' is deprecated."
,
PendingDeprecationWarning
,
stacklevel
=
2
)
def
managed
(
flag
=
True
,
using
=
None
):
warnings
.
warn
(
"'managed' no longer serves a purpose."
,
...
...
@@ -281,7 +279,9 @@ def commit_on_success_unless_managed(using=None):
"""
Transitory API to preserve backwards-compatibility while refactoring.
"""
if
is_managed
(
using
):
if
get_autocommit
(
using
):
return
commit_on_success
(
using
)
else
:
def
entering
(
using
):
pass
...
...
@@ -289,5 +289,3 @@ def commit_on_success_unless_managed(using=None):
set_dirty
(
using
=
using
)
return
_transaction_func
(
entering
,
exiting
,
using
)
else
:
return
commit_on_success
(
using
)
django/middleware/transaction.py
Dosyayı görüntüle @
3bdc7a6a
...
...
@@ -23,7 +23,7 @@ class TransactionMiddleware(object):
def
process_response
(
self
,
request
,
response
):
"""Commits and leaves transaction management."""
if
transaction
.
is_managed
():
if
not
transaction
.
get_autocommit
():
if
transaction
.
is_dirty
():
# Note: it is possible that the commit fails. If the reason is
# closed connection or some similar reason, then there is
...
...
docs/internals/deprecation.txt
Dosyayı görüntüle @
3bdc7a6a
...
...
@@ -351,6 +351,7 @@ these changes.
* The following private APIs will be removed:
- ``django.db.close_connection()``
- ``django.db.backends.creation.BaseDatabaseCreation.set_autocommit()``
- ``django.db.transaction.is_managed()``
- ``django.db.transaction.managed()``
- ``django.db.transaction.commit_unless_managed()``
- ``django.db.transaction.rollback_unless_managed()``
...
...
tests/middleware/tests.py
Dosyayı görüntüle @
3bdc7a6a
...
...
@@ -689,7 +689,7 @@ class TransactionMiddlewareTest(TransactionTestCase):
def
test_request
(
self
):
TransactionMiddleware
()
.
process_request
(
self
.
request
)
self
.
assert
True
(
transaction
.
is_managed
())
self
.
assert
False
(
transaction
.
get_autocommit
())
def
test_managed_response
(
self
):
transaction
.
enter_transaction_management
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment