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
4a03d348
Kaydet (Commit)
4a03d348
authored
Ock 17, 2015
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Removed BaseCommand.requires_model_validation per deprecation timeline.
üst
18192b9f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
4 additions
and
75 deletions
+4
-75
base.py
django/core/management/base.py
+3
-42
custom-management-commands.txt
docs/howto/custom-management-commands.txt
+1
-17
validation_command.py
...s/admin_scripts/management/commands/validation_command.py
+0
-11
tests.py
tests/admin_scripts/tests.py
+0
-5
No files found.
django/core/management/base.py
Dosyayı görüntüle @
4a03d348
...
...
@@ -191,18 +191,6 @@ class BaseCommand(object):
is the list of application's configuration provided by the
app registry.
``requires_model_validation``
DEPRECATED - This value will only be used if requires_system_checks
has not been provided. Defining both ``requires_system_checks`` and
``requires_model_validation`` will result in an error.
A boolean; if ``True``, validation of installed models will be
performed prior to executing the command. Default value is
``True``. To validate an individual application's models
rather than all applications' models, call
``self.validate(app_config)`` from ``handle()``, where ``app_config``
is the application's configuration provided by the app registry.
``leave_locale_alone``
A boolean indicating whether the locale set in settings should be
preserved during the execution of the command instead of translations
...
...
@@ -230,11 +218,7 @@ class BaseCommand(object):
can_import_settings
=
True
output_transaction
=
False
# Whether to wrap the output in a "BEGIN; COMMIT;"
leave_locale_alone
=
False
# Uncomment the following line of code after deprecation plan for
# requires_model_validation comes to completion:
#
# requires_system_checks = True
requires_system_checks
=
True
def
__init__
(
self
,
stdout
=
None
,
stderr
=
None
,
no_color
=
False
):
self
.
stdout
=
OutputWrapper
(
stdout
or
sys
.
stdout
)
...
...
@@ -245,29 +229,6 @@ class BaseCommand(object):
self
.
style
=
color_style
()
self
.
stderr
.
style_func
=
self
.
style
.
ERROR
# `requires_model_validation` is deprecated in favor of
# `requires_system_checks`. If both options are present, an error is
# raised. Otherwise the present option is used. If none of them is
# defined, the default value (True) is used.
has_old_option
=
hasattr
(
self
,
'requires_model_validation'
)
has_new_option
=
hasattr
(
self
,
'requires_system_checks'
)
if
has_old_option
:
warnings
.
warn
(
'"requires_model_validation" is deprecated '
'in favor of "requires_system_checks".'
,
RemovedInDjango19Warning
)
if
has_old_option
and
has_new_option
:
raise
ImproperlyConfigured
(
'Command
%
s defines both "requires_model_validation" '
'and "requires_system_checks", which is illegal. Use only '
'"requires_system_checks".'
%
self
.
__class__
.
__name__
)
self
.
requires_system_checks
=
(
self
.
requires_system_checks
if
has_new_option
else
self
.
requires_model_validation
if
has_old_option
else
True
)
@property
def
use_argparse
(
self
):
return
not
bool
(
self
.
option_list
)
...
...
@@ -404,8 +365,8 @@ class BaseCommand(object):
def
execute
(
self
,
*
args
,
**
options
):
"""
Try to execute this command, performing system checks if needed (as
controlled by
attributes ``self.requires_system_checks`` and
``self.requires_model_validation``, except if
force-skipped).
controlled by
the ``requires_system_checks`` attribute, except if
force-skipped).
"""
if
options
.
get
(
'no_color'
):
self
.
style
=
no_style
()
...
...
docs/howto/custom-management-commands.txt
Dosyayı görüntüle @
4a03d348
...
...
@@ -282,23 +282,7 @@ All attributes can be set in your derived class and can be used in
.. versionadded:: 1.7
A boolean; if ``True``, the entire Django project will be checked for
potential problems prior to executing the command. If
``requires_system_checks`` is missing, the value of
``requires_model_validation`` is used. If the latter flag is missing
as well, the default value (``True``) is used. Defining both
``requires_system_checks`` and ``requires_model_validation`` will result
in an error.
.. attribute:: BaseCommand.requires_model_validation
.. deprecated:: 1.7
Replaced by ``requires_system_checks``
A boolean; if ``True``, validation of installed models will be
performed prior to executing the command. Default value is
``True``. To validate an individual application's models
rather than all applications' models, call
:meth:`~BaseCommand.validate` from :meth:`~BaseCommand.handle`.
potential problems prior to executing the command. Default value is ``True``.
.. attribute:: BaseCommand.leave_locale_alone
...
...
tests/admin_scripts/management/commands/validation_command.py
deleted
100644 → 0
Dosyayı görüntüle @
18192b9f
from
django.core.management.base
import
BaseCommand
class
InvalidCommand
(
BaseCommand
):
help
=
(
"Test raising an error if both requires_system_checks "
"and requires_model_validation are defined."
)
requires_system_checks
=
True
requires_model_validation
=
True
def
handle
(
self
,
**
options
):
pass
tests/admin_scripts/tests.py
Dosyayı görüntüle @
4a03d348
...
...
@@ -1662,11 +1662,6 @@ class CommandTypes(AdminScriptTestCase):
self
.
assertOutput
(
out
,
"EXECUTE:LabelCommand label=testlabel, options=[('no_color', False), ('pythonpath', None), ('settings', None), ('traceback', False), ('verbosity', 1)]"
)
self
.
assertOutput
(
out
,
"EXECUTE:LabelCommand label=anotherlabel, options=[('no_color', False), ('pythonpath', None), ('settings', None), ('traceback', False), ('verbosity', 1)]"
)
@ignore_warnings
(
category
=
RemovedInDjango19Warning
)
def
test_requires_model_validation_and_requires_system_checks_both_defined
(
self
):
from
.management.commands.validation_command
import
InvalidCommand
self
.
assertRaises
(
ImproperlyConfigured
,
InvalidCommand
)
class
Discovery
(
TestCase
):
...
...
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