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
ae4125ff
Kaydet (Commit)
ae4125ff
authored
Tem 23, 2012
tarafından
Aymeric Augustin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Removed a Python 3-compatibility hack.
Thanks Preston Holmes for the patch.
üst
ebc89a80
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
13 deletions
+7
-13
base.py
django/db/models/base.py
+7
-13
No files found.
django/db/models/base.py
Dosyayı görüntüle @
ae4125ff
...
...
@@ -34,7 +34,10 @@ class ModelBase(type):
"""
def
__new__
(
cls
,
name
,
bases
,
attrs
):
super_new
=
super
(
ModelBase
,
cls
)
.
__new__
parents
=
[
b
for
b
in
bases
if
isinstance
(
b
,
ModelBase
)]
# six.with_metaclass() inserts an extra class called 'NewBase' in the
# inheritance tree: Model -> NewBase -> object. Ignore this class.
parents
=
[
b
for
b
in
bases
if
isinstance
(
b
,
ModelBase
)
and
not
(
b
.
__name__
==
'NewBase'
and
b
.
__mro__
==
(
b
,
object
))]
if
not
parents
:
# If this isn't a subclass of Model, don't do anything special.
return
super_new
(
cls
,
name
,
bases
,
attrs
)
...
...
@@ -276,8 +279,7 @@ class ModelState(object):
# This impacts validation only; it has no effect on the actual save.
self
.
adding
=
True
class
ModelWithoutMeta
(
object
):
class
Model
(
six
.
with_metaclass
(
ModelBase
,
object
)):
_deferred
=
False
def
__init__
(
self
,
*
args
,
**
kwargs
):
...
...
@@ -370,7 +372,7 @@ class ModelWithoutMeta(object):
pass
if
kwargs
:
raise
TypeError
(
"'
%
s' is an invalid keyword argument for this function"
%
kwargs
.
keys
()[
0
])
super
(
Model
WithoutMeta
,
self
)
.
__init__
()
super
(
Model
,
self
)
.
__init__
()
signals
.
post_init
.
send
(
sender
=
self
.
__class__
,
instance
=
self
)
def
__repr__
(
self
):
...
...
@@ -402,7 +404,7 @@ class ModelWithoutMeta(object):
only module-level classes can be pickled by the default path.
"""
if
not
self
.
_deferred
:
return
super
(
Model
WithoutMeta
,
self
)
.
__reduce__
()
return
super
(
Model
,
self
)
.
__reduce__
()
data
=
self
.
__dict__
defers
=
[]
for
field
in
self
.
_meta
.
fields
:
...
...
@@ -877,14 +879,6 @@ class ModelWithoutMeta(object):
raise
ValidationError
(
errors
)
# For unknown reasons, six.with_metaclass doesn't work correctly for Model.
# Fallback to exec'ing the appropriate syntax for each Python version.
if
six
.
PY3
:
six
.
exec_
(
"class Model(ModelWithoutMeta, metaclass=ModelBase): pass"
)
else
:
six
.
exec_
(
"class Model(ModelWithoutMeta): __metaclass__ = ModelBase"
)
############################################
# HELPER FUNCTIONS (CURRIED MODEL METHODS) #
...
...
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