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
3188b49e
Kaydet (Commit)
3188b49e
authored
Ara 01, 2016
tarafından
Jaap Roes
Kaydeden (comit)
Claude Paroz
Ara 21, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #25753 -- Made get_format() cache the formats from Django settings
üst
1206d7fa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
26 deletions
+34
-26
formats.py
django/utils/formats.py
+34
-26
No files found.
django/utils/formats.py
Dosyayı görüntüle @
3188b49e
...
@@ -112,32 +112,40 @@ def get_format(format_type, lang=None, use_l10n=None):
...
@@ -112,32 +112,40 @@ def get_format(format_type, lang=None, use_l10n=None):
be localized (or not), overriding the value of settings.USE_L10N.
be localized (or not), overriding the value of settings.USE_L10N.
"""
"""
format_type
=
force_str
(
format_type
)
format_type
=
force_str
(
format_type
)
if
use_l10n
or
(
use_l10n
is
None
and
settings
.
USE_L10N
):
use_l10n
=
use_l10n
or
(
use_l10n
is
None
and
settings
.
USE_L10N
)
if
lang
is
None
:
if
use_l10n
and
lang
is
None
:
lang
=
get_language
()
lang
=
get_language
()
cache_key
=
(
format_type
,
lang
)
cache_key
=
(
format_type
,
lang
)
try
:
try
:
cached
=
_format_cache
[
cache_key
]
return
_format_cache
[
cache_key
]
if
cached
is
not
None
:
except
KeyError
:
return
cached
pass
except
KeyError
:
for
module
in
get_format_modules
(
lang
):
# The requested format_type has not been cached yet. Try to find it in any
try
:
# of the format_modules for the given lang if l10n is enabled. If it's not
val
=
getattr
(
module
,
format_type
)
# there or if l10n is disabled, fall back to the project settings.
for
iso_input
in
ISO_INPUT_FORMATS
.
get
(
format_type
,
()):
val
=
None
if
iso_input
not
in
val
:
if
use_l10n
:
if
isinstance
(
val
,
tuple
):
for
module
in
get_format_modules
(
lang
):
val
=
list
(
val
)
try
:
val
.
append
(
iso_input
)
val
=
getattr
(
module
,
format_type
)
_format_cache
[
cache_key
]
=
val
if
val
is
not
None
:
return
val
break
except
AttributeError
:
except
AttributeError
:
pass
pass
_format_cache
[
cache_key
]
=
None
if
val
is
None
:
if
format_type
not
in
FORMAT_SETTINGS
:
if
format_type
not
in
FORMAT_SETTINGS
:
return
format_type
return
format_type
# Return the general setting by default
val
=
getattr
(
settings
,
format_type
)
return
getattr
(
settings
,
format_type
)
elif
format_type
in
ISO_INPUT_FORMATS
.
keys
():
# If a list of input formats from one of the format_modules was
# retrieved, make sure the ISO_INPUT_FORMATS are in this list.
val
=
list
(
val
)
for
iso_input
in
ISO_INPUT_FORMATS
.
get
(
format_type
,
()):
if
iso_input
not
in
val
:
val
.
append
(
iso_input
)
_format_cache
[
cache_key
]
=
val
return
val
get_format_lazy
=
lazy
(
get_format
,
six
.
text_type
,
list
,
tuple
)
get_format_lazy
=
lazy
(
get_format
,
six
.
text_type
,
list
,
tuple
)
...
...
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