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
b59f963a
Kaydet (Commit)
b59f963a
authored
Şub 12, 2016
tarafından
Alexey Kotlyarov
Kaydeden (comit)
Tim Graham
Şub 15, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #26212 -- Made forms.FileField and translation.lazy_number() picklable.
üst
1ac7fdcd
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
0 deletions
+24
-0
__init__.py
django/utils/translation/__init__.py
+7
-0
1.8.10.txt
docs/releases/1.8.10.txt
+3
-0
1.9.3.txt
docs/releases/1.9.3.txt
+3
-0
test_fields.py
tests/forms_tests/tests/test_fields.py
+3
-0
tests.py
tests/i18n/tests.py
+8
-0
No files found.
django/utils/translation/__init__.py
Dosyayı görüntüle @
b59f963a
...
...
@@ -106,6 +106,8 @@ def lazy_number(func, resultclass, number=None, **kwargs):
kwargs
[
'number'
]
=
number
proxy
=
lazy
(
func
,
resultclass
)(
**
kwargs
)
else
:
original_kwargs
=
kwargs
.
copy
()
class
NumberAwareString
(
resultclass
):
def
__bool__
(
self
):
return
bool
(
kwargs
[
'singular'
])
...
...
@@ -134,9 +136,14 @@ def lazy_number(func, resultclass, number=None, **kwargs):
return
translated
proxy
=
lazy
(
lambda
**
kwargs
:
NumberAwareString
(),
NumberAwareString
)(
**
kwargs
)
proxy
.
__reduce__
=
lambda
:
(
_lazy_number_unpickle
,
(
func
,
resultclass
,
number
,
original_kwargs
))
return
proxy
def
_lazy_number_unpickle
(
func
,
resultclass
,
number
,
kwargs
):
return
lazy_number
(
func
,
resultclass
,
number
=
number
,
**
kwargs
)
def
ngettext_lazy
(
singular
,
plural
,
number
=
None
):
return
lazy_number
(
ngettext
,
str
,
singular
=
singular
,
plural
=
plural
,
number
=
number
)
...
...
docs/releases/1.8.10.txt
Dosyayı görüntüle @
b59f963a
...
...
@@ -14,3 +14,6 @@ Bugfixes
* Added system checks for query name clashes of hidden relationships
(:ticket:`26162`).
* Made ``forms.FileField`` and ``utils.translation.lazy_number()`` picklable
(:ticket:`26212`).
docs/releases/1.9.3.txt
Dosyayı görüntüle @
b59f963a
...
...
@@ -24,3 +24,6 @@ Bugfixes
* Fixed regression with an ``__in=qs`` lookup for a ``ForeignKey`` with
``to_field`` set (:ticket:`26196`).
* Made ``forms.FileField`` and ``utils.translation.lazy_number()`` picklable
(:ticket:`26212`).
tests/forms_tests/tests/test_fields.py
Dosyayı görüntüle @
b59f963a
...
...
@@ -949,6 +949,9 @@ class FieldsTests(SimpleTestCase):
# with here)
self
.
assertTrue
(
f
.
has_changed
(
'resume.txt'
,
{
'filename'
:
'resume.txt'
,
'content'
:
'My resume'
}))
def
test_file_picklable
(
self
):
self
.
assertIsInstance
(
pickle
.
loads
(
pickle
.
dumps
(
FileField
())),
FileField
)
# ImageField ##################################################################
@skipIf
(
Image
is
None
,
"Pillow is required to test ImageField"
)
...
...
tests/i18n/tests.py
Dosyayı görüntüle @
b59f963a
...
...
@@ -243,6 +243,14 @@ class TranslationTests(SimpleTestCase):
self
.
assertTrue
(
ungettext_lazy
(
'
%
d good result'
,
'
%
d good results'
))
self
.
assertFalse
(
ungettext_lazy
(
''
,
''
))
def
test_ungettext_lazy_pickle
(
self
):
s1
=
ungettext_lazy
(
'
%
d good result'
,
'
%
d good results'
)
self
.
assertEqual
(
s1
%
1
,
'1 good result'
)
self
.
assertEqual
(
s1
%
8
,
'8 good results'
)
s2
=
pickle
.
loads
(
pickle
.
dumps
(
s1
))
self
.
assertEqual
(
s2
%
1
,
'1 good result'
)
self
.
assertEqual
(
s2
%
8
,
'8 good results'
)
@override_settings
(
LOCALE_PATHS
=
extended_locale_paths
)
def
test_pgettext
(
self
):
trans_real
.
_active
=
local
()
...
...
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