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
b02f08e0
Kaydet (Commit)
b02f08e0
authored
Eyl 02, 2015
tarafından
Tom Christie
Kaydeden (comit)
Tim Graham
Eyl 18, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #25034 -- Converted caches ImproperlyConfigured error to a system check.
üst
f33b3ebd
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
65 additions
and
4 deletions
+65
-4
__init__.py
django/core/cache/__init__.py
+0
-4
__init__.py
django/core/checks/__init__.py
+1
-0
caches.py
django/core/checks/caches.py
+18
-0
registry.py
django/core/checks/registry.py
+1
-0
checks.txt
docs/ref/checks.txt
+10
-0
test_caches.py
tests/check_framework/test_caches.py
+35
-0
No files found.
django/core/cache/__init__.py
Dosyayı görüntüle @
b02f08e0
...
...
@@ -19,7 +19,6 @@ from django.core import signals
from
django.core.cache.backends.base
import
(
BaseCache
,
CacheKeyWarning
,
InvalidCacheBackendError
,
)
from
django.core.exceptions
import
ImproperlyConfigured
from
django.utils.module_loading
import
import_string
__all__
=
[
...
...
@@ -29,9 +28,6 @@ __all__ = [
DEFAULT_CACHE_ALIAS
=
'default'
if
DEFAULT_CACHE_ALIAS
not
in
settings
.
CACHES
:
raise
ImproperlyConfigured
(
"You must define a '
%
s' cache"
%
DEFAULT_CACHE_ALIAS
)
def
_create_cache
(
backend
,
**
kwargs
):
try
:
...
...
django/core/checks/__init__.py
Dosyayı görüntüle @
b02f08e0
...
...
@@ -8,6 +8,7 @@ from .messages import (
from
.registry
import
Tags
,
register
,
run_checks
,
tag_exists
# Import these to force registration of checks
import
django.core.checks.caches
# NOQA isort:skip
import
django.core.checks.compatibility.django_1_8_0
# NOQA isort:skip
import
django.core.checks.model_checks
# NOQA isort:skip
import
django.core.checks.security.base
# NOQA isort:skip
...
...
django/core/checks/caches.py
0 → 100644
Dosyayı görüntüle @
b02f08e0
from
__future__
import
unicode_literals
from
django.conf
import
settings
from
django.core.cache
import
DEFAULT_CACHE_ALIAS
from
.
import
Error
,
Tags
,
register
E001
=
Error
(
"You must define a '
%
s' cache in your CACHES setting."
%
DEFAULT_CACHE_ALIAS
,
id
=
'caches.E001'
,
)
@register
(
Tags
.
caches
)
def
check_default_cache_is_configured
(
app_configs
,
**
kwargs
):
if
DEFAULT_CACHE_ALIAS
not
in
settings
.
CACHES
:
return
[
E001
]
return
[]
django/core/checks/registry.py
Dosyayı görüntüle @
b02f08e0
...
...
@@ -11,6 +11,7 @@ class Tags(object):
Built-in tags for internal checks.
"""
admin
=
'admin'
caches
=
'caches'
compatibility
=
'compatibility'
models
=
'models'
security
=
'security'
...
...
docs/ref/checks.txt
Dosyayı görüntüle @
b02f08e0
...
...
@@ -80,6 +80,7 @@ Django's system checks are organized using the following tags:
* ``compatibility``: Flagging potential problems with version upgrades.
* ``security``: Checks security related configuration.
* ``templates``: Checks template related configuration.
* ``caches``: Checks cache related configuration.
Some checks may be registered with multiple tags.
...
...
@@ -569,3 +570,12 @@ configured:
* **templates.E001**: You have ``'APP_DIRS': True`` in your
:setting:`TEMPLATES` but also specify ``'loaders'`` in ``OPTIONS``. Either
remove ``APP_DIRS`` or remove the ``'loaders'`` option.
Caches
------
The following checks verify that your :setting:`CACHES` setting is correctly
configured:
* **caches.E001**: You must define a ``'default'`` cache in your
:setting:`CACHES` setting.
tests/check_framework/test_caches.py
0 → 100644
Dosyayı görüntüle @
b02f08e0
from
django.core.checks.caches
import
E001
from
django.test
import
SimpleTestCase
from
django.test.utils
import
override_settings
class
CheckCacheSettingsAppDirsTest
(
SimpleTestCase
):
VALID_CACHES_CONFIGURATION
=
{
'default'
:
{
'BACKEND'
:
'django.core.cache.backends.locmem.LocMemCache'
,
},
}
INVALID_CACHES_CONFIGURATION
=
{
'other'
:
{
'BACKEND'
:
'django.core.cache.backends.locmem.LocMemCache'
,
},
}
@property
def
func
(
self
):
from
django.core.checks.caches
import
check_default_cache_is_configured
return
check_default_cache_is_configured
@override_settings
(
CACHES
=
VALID_CACHES_CONFIGURATION
)
def
test_default_cache_included
(
self
):
"""
Don't error if 'default' is present in CACHES setting.
"""
self
.
assertEqual
(
self
.
func
(
None
),
[])
@override_settings
(
CACHES
=
INVALID_CACHES_CONFIGURATION
)
def
test_default_cache_not_included
(
self
):
"""
Error if 'default' not present in CACHES setting.
"""
self
.
assertEqual
(
self
.
func
(
None
),
[
E001
])
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