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
576ec12f
Kaydet (Commit)
576ec12f
authored
Agu 08, 2012
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
[py3] Replaced __nonzero__ by __bool__
Of course, __nonzero__ alias has been kept for Python 2 compatibility.
üst
12cda89f
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
15 additions
and
8 deletions
+15
-8
context_processors.py
django/contrib/auth/context_processors.py
+2
-1
base.py
django/core/files/base.py
+4
-2
query.py
django/db/models/query.py
+2
-1
saferef.py
django/dispatch/saferef.py
+2
-1
formsets.py
django/forms/formsets.py
+2
-1
tree.py
django/utils/tree.py
+2
-1
optimization.txt
docs/topics/db/optimization.txt
+1
-1
No files found.
django/contrib/auth/context_processors.py
Dosyayı görüntüle @
576ec12f
...
@@ -11,8 +11,9 @@ class PermLookupDict(object):
...
@@ -11,8 +11,9 @@ class PermLookupDict(object):
def
__getitem__
(
self
,
perm_name
):
def
__getitem__
(
self
,
perm_name
):
return
self
.
user
.
has_perm
(
"
%
s.
%
s"
%
(
self
.
module_name
,
perm_name
))
return
self
.
user
.
has_perm
(
"
%
s.
%
s"
%
(
self
.
module_name
,
perm_name
))
def
__
nonzero
__
(
self
):
def
__
bool
__
(
self
):
return
self
.
user
.
has_module_perms
(
self
.
module_name
)
return
self
.
user
.
has_module_perms
(
self
.
module_name
)
__nonzero__
=
__bool__
# Python 2
class
PermWrapper
(
object
):
class
PermWrapper
(
object
):
...
...
django/core/files/base.py
Dosyayı görüntüle @
576ec12f
...
@@ -26,8 +26,9 @@ class File(FileProxyMixin):
...
@@ -26,8 +26,9 @@ class File(FileProxyMixin):
def
__repr__
(
self
):
def
__repr__
(
self
):
return
"<
%
s:
%
s>"
%
(
self
.
__class__
.
__name__
,
self
or
"None"
)
return
"<
%
s:
%
s>"
%
(
self
.
__class__
.
__name__
,
self
or
"None"
)
def
__
nonzero
__
(
self
):
def
__
bool
__
(
self
):
return
bool
(
self
.
name
)
return
bool
(
self
.
name
)
__nonzero__
=
__bool__
# Python 2
def
__len__
(
self
):
def
__len__
(
self
):
return
self
.
size
return
self
.
size
...
@@ -135,8 +136,9 @@ class ContentFile(File):
...
@@ -135,8 +136,9 @@ class ContentFile(File):
def
__str__
(
self
):
def
__str__
(
self
):
return
'Raw content'
return
'Raw content'
def
__
nonzero
__
(
self
):
def
__
bool
__
(
self
):
return
True
return
True
__nonzero__
=
__bool__
# Python 2
def
open
(
self
,
mode
=
None
):
def
open
(
self
,
mode
=
None
):
self
.
seek
(
0
)
self
.
seek
(
0
)
...
...
django/db/models/query.py
Dosyayı görüntüle @
576ec12f
...
@@ -120,7 +120,7 @@ class QuerySet(object):
...
@@ -120,7 +120,7 @@ class QuerySet(object):
if
len
(
self
.
_result_cache
)
<=
pos
:
if
len
(
self
.
_result_cache
)
<=
pos
:
self
.
_fill_cache
()
self
.
_fill_cache
()
def
__
nonzero
__
(
self
):
def
__
bool
__
(
self
):
if
self
.
_prefetch_related_lookups
and
not
self
.
_prefetch_done
:
if
self
.
_prefetch_related_lookups
and
not
self
.
_prefetch_done
:
# We need all the results in order to be able to do the prefetch
# We need all the results in order to be able to do the prefetch
# in one go. To minimize code duplication, we use the __len__
# in one go. To minimize code duplication, we use the __len__
...
@@ -134,6 +134,7 @@ class QuerySet(object):
...
@@ -134,6 +134,7 @@ class QuerySet(object):
except
StopIteration
:
except
StopIteration
:
return
False
return
False
return
True
return
True
__nonzero__
=
__bool__
# Python 2
def
__contains__
(
self
,
val
):
def
__contains__
(
self
,
val
):
# The 'in' operator works without this method, due to __iter__. This
# The 'in' operator works without this method, due to __iter__. This
...
...
django/dispatch/saferef.py
Dosyayı görüntüle @
576ec12f
...
@@ -152,9 +152,10 @@ class BoundMethodWeakref(object):
...
@@ -152,9 +152,10 @@ class BoundMethodWeakref(object):
__repr__
=
__str__
__repr__
=
__str__
def
__
nonzero
__
(
self
):
def
__
bool
__
(
self
):
"""Whether we are still a valid reference"""
"""Whether we are still a valid reference"""
return
self
()
is
not
None
return
self
()
is
not
None
__nonzero__
=
__bool__
# Python 2
def
__eq__
(
self
,
other
):
def
__eq__
(
self
,
other
):
"""Compare with another reference"""
"""Compare with another reference"""
...
...
django/forms/formsets.py
Dosyayı görüntüle @
576ec12f
...
@@ -65,9 +65,10 @@ class BaseFormSet(StrAndUnicode):
...
@@ -65,9 +65,10 @@ class BaseFormSet(StrAndUnicode):
def
__len__
(
self
):
def
__len__
(
self
):
return
len
(
self
.
forms
)
return
len
(
self
.
forms
)
def
__
nonzero
__
(
self
):
def
__
bool
__
(
self
):
"""All formsets have a management form which is not included in the length"""
"""All formsets have a management form which is not included in the length"""
return
True
return
True
__nonzero__
=
__bool__
# Python 2
def
_management_form
(
self
):
def
_management_form
(
self
):
"""Returns the ManagementForm instance for this FormSet."""
"""Returns the ManagementForm instance for this FormSet."""
...
...
django/utils/tree.py
Dosyayı görüntüle @
576ec12f
...
@@ -68,11 +68,12 @@ class Node(object):
...
@@ -68,11 +68,12 @@ class Node(object):
"""
"""
return
len
(
self
.
children
)
return
len
(
self
.
children
)
def
__
nonzero
__
(
self
):
def
__
bool
__
(
self
):
"""
"""
For truth value testing.
For truth value testing.
"""
"""
return
bool
(
self
.
children
)
return
bool
(
self
.
children
)
__nonzero__
=
__bool__
# Python 2
def
__contains__
(
self
,
other
):
def
__contains__
(
self
,
other
):
"""
"""
...
...
docs/topics/db/optimization.txt
Dosyayı görüntüle @
576ec12f
...
@@ -230,7 +230,7 @@ It is optimal because:
...
@@ -230,7 +230,7 @@ It is optimal because:
#. Use of :ttag:`with` means that we store ``user.emails.all`` in a variable
#. Use of :ttag:`with` means that we store ``user.emails.all`` in a variable
for later use, allowing its cache to be re-used.
for later use, allowing its cache to be re-used.
#. The line ``{% if emails %}`` causes ``QuerySet.__
nonzero
__()`` to be called,
#. The line ``{% if emails %}`` causes ``QuerySet.__
bool
__()`` to be called,
which causes the ``user.emails.all()`` query to be run on the database, and
which causes the ``user.emails.all()`` query to be run on the database, and
at the least the first line to be turned into an ORM object. If there aren't
at the least the first line to be turned into an ORM object. If there aren't
any results, it will return False, otherwise True.
any results, it will return False, otherwise True.
...
...
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