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
5cc74620
Kaydet (Commit)
5cc74620
authored
Agu 04, 2017
tarafından
Sergey Fedoseev
Kaydeden (comit)
Tim Graham
Agu 11, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #28459 -- Optimized ModelState instantiation.
üst
97cb3bd1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
7 deletions
+23
-7
base.py
django/db/models/base.py
+15
-7
test_state.py
tests/model_regress/test_state.py
+8
-0
No files found.
django/db/models/base.py
Dosyayı görüntüle @
5cc74620
...
...
@@ -370,15 +370,23 @@ class ModelBase(type):
return
cls
.
_meta
.
default_manager
class
ModelStateFieldsCacheDescriptor
:
def
__get__
(
self
,
instance
,
cls
=
None
):
if
instance
is
None
:
return
self
res
=
instance
.
fields_cache
=
{}
return
res
class
ModelState
:
"""Store model instance state."""
d
ef
__init__
(
self
,
db
=
None
):
self
.
db
=
db
# If true, uniqueness validation checks will consider this a new, as-yet-unsaved object.
# Necessary for correct validation of new instances of objects with explicit (non-auto) PKs.
# This impacts validation only; it has no effect
on the actual save.
self
.
adding
=
True
self
.
fields_cache
=
{}
d
b
=
None
# If true, uniqueness validation checks will consider this a new, unsaved
# object. Necessary for correct validation of new instances of objects with
# explicit (non-auto) PKs. This impacts validation only; it has no effect
#
on the actual save.
adding
=
True
fields_cache
=
ModelStateFieldsCacheDescriptor
()
class
Model
(
metaclass
=
ModelBase
):
...
...
tests/model_regress/test_state.py
0 → 100644
Dosyayı görüntüle @
5cc74620
from
django.db.models.base
import
ModelState
,
ModelStateFieldsCacheDescriptor
from
django.test
import
SimpleTestCase
class
ModelStateTests
(
SimpleTestCase
):
def
test_fields_cache_descriptor
(
self
):
self
.
assertIsInstance
(
ModelState
.
fields_cache
,
ModelStateFieldsCacheDescriptor
)
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