summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2016-10-02 18:23:32 +0200
committerClaude Paroz <claude@2xlibre.net>2016-10-02 20:31:56 +0200
commit122c90a43b2486bf278def8f068b6d1cebaa66f9 (patch)
tree658c7d9a69da56912b3ae2142cc94346263c767b
parentbae1160c3f70a6156b36792ad4fb59e9d0b82540 (diff)
Fixed #27305 -- Removed BaseCommand.can_import_settings unused attribute
Thanks Tim Graham for the review.
-rw-r--r--django/core/management/base.py20
-rw-r--r--django/core/management/templates.py3
-rw-r--r--docs/howto/custom-management-commands.txt13
-rw-r--r--docs/releases/1.11.txt2
-rw-r--r--docs/releases/1.6.txt2
-rw-r--r--tests/user_commands/management/commands/leave_locale_alone_false.py1
-rw-r--r--tests/user_commands/management/commands/leave_locale_alone_true.py1
7 files changed, 3 insertions, 39 deletions
diff --git a/django/core/management/base.py b/django/core/management/base.py
index 6aaf2fc4bb..cdc673a479 100644
--- a/django/core/management/base.py
+++ b/django/core/management/base.py
@@ -151,12 +151,6 @@ class BaseCommand(object):
Several attributes affect behavior at various steps along the way:
- ``can_import_settings``
- A boolean indicating whether the command needs to be able to
- import Django settings; if ``True``, ``execute()`` will verify
- that this is possible before proceeding. Default value is
- ``True``.
-
``help``
A short description of the command, which will be printed in
help messages.
@@ -192,17 +186,12 @@ class BaseCommand(object):
that is locale-sensitive and such content shouldn't contain any
translations (like it happens e.g. with django.contrib.auth
permissions) as activating any locale might cause unintended effects.
-
- This option can't be False when the can_import_settings option is set
- to False too because attempting to deactivate translations needs access
- to settings. This condition will generate a CommandError.
"""
# Metadata about this command.
help = ''
# Configuration shortcuts that alter various logic.
_called_from_command_line = False
- can_import_settings = True
output_transaction = False # Whether to wrap the output in a "BEGIN; COMMIT;"
leave_locale_alone = False
requires_migrations_checks = False
@@ -326,15 +315,6 @@ class BaseCommand(object):
saved_locale = None
if not self.leave_locale_alone:
- # Only mess with locales if we can assume we have a working
- # settings file, because django.utils.translation requires settings
- # (The final saying about whether the i18n machinery is active will be
- # found in the value of the USE_I18N setting)
- if not self.can_import_settings:
- raise CommandError("Incompatible values of 'leave_locale_alone' "
- "(%s) and 'can_import_settings' (%s) command "
- "options." % (self.leave_locale_alone,
- self.can_import_settings))
# Deactivate translations, because django-admin creates database
# content like permissions, and those shouldn't contain any
# translations.
diff --git a/django/core/management/templates.py b/django/core/management/templates.py
index 466ea935d8..ca4b935d79 100644
--- a/django/core/management/templates.py
+++ b/django/core/management/templates.py
@@ -35,9 +35,6 @@ class TemplateCommand(BaseCommand):
:param options: The additional variables passed to project or app templates
"""
requires_system_checks = False
- # Can't import settings during this command, because they haven't
- # necessarily been created.
- can_import_settings = False
# The supported URL schemes
url_schemes = ['http', 'https', 'ftp']
# Can't perform any active locale changes during this command, because
diff --git a/docs/howto/custom-management-commands.txt b/docs/howto/custom-management-commands.txt
index d47fecbd60..a077a2945b 100644
--- a/docs/howto/custom-management-commands.txt
+++ b/docs/howto/custom-management-commands.txt
@@ -148,7 +148,6 @@ support code::
class Command(BaseCommand):
...
- can_import_settings = True
def handle(self, *args, **options):
@@ -208,13 +207,6 @@ Attributes
All attributes can be set in your derived class and can be used in
:class:`BaseCommand`’s :ref:`subclasses<ref-basecommand-subclasses>`.
-.. attribute:: BaseCommand.can_import_settings
-
- A boolean indicating whether the command needs to be able to
- import Django settings; if ``True``, ``execute()`` will verify
- that this is possible before proceeding. Default value is
- ``True``.
-
.. attribute:: BaseCommand.help
A short description of the command, which will be printed in the
@@ -261,11 +253,6 @@ All attributes can be set in your derived class and can be used in
effects. Seethe `Management commands and locales`_ section above for
further details.
- This option can't be ``False`` when the
- :data:`~BaseCommand.can_import_settings` option is set to ``False`` too
- because attempting to set the locale needs access to settings. This
- condition will generate a :exc:`CommandError`.
-
.. attribute:: BaseCommand.style
An instance attribute that helps create colored output when writing to
diff --git a/docs/releases/1.11.txt b/docs/releases/1.11.txt
index bc780a5031..96fb2e4ae9 100644
--- a/docs/releases/1.11.txt
+++ b/docs/releases/1.11.txt
@@ -278,6 +278,8 @@ Management Commands
* The new :option:`loaddata --exclude` option allows excluding models and apps
while loading data from fixtures.
+* The unused ``BaseCommand.can_import_settings`` attribute is removed.
+
Migrations
~~~~~~~~~~
diff --git a/docs/releases/1.6.txt b/docs/releases/1.6.txt
index 1be016e336..f97704688d 100644
--- a/docs/releases/1.6.txt
+++ b/docs/releases/1.6.txt
@@ -189,7 +189,7 @@ Minor features
* For custom management commands: Verification of the presence of valid
settings in commands that ask for it by using the
- :attr:`~django.core.management.BaseCommand.can_import_settings` internal
+ ``BaseCommand.can_import_settings`` internal
option is now performed independently from handling of the locale that
should be active during the execution of the command. The latter can now be
influenced by the new
diff --git a/tests/user_commands/management/commands/leave_locale_alone_false.py b/tests/user_commands/management/commands/leave_locale_alone_false.py
index e03ad1cab0..aa3e20664a 100644
--- a/tests/user_commands/management/commands/leave_locale_alone_false.py
+++ b/tests/user_commands/management/commands/leave_locale_alone_false.py
@@ -4,7 +4,6 @@ from django.utils import translation
class Command(BaseCommand):
- can_import_settings = True
leave_locale_alone = False
def handle(self, *args, **options):
diff --git a/tests/user_commands/management/commands/leave_locale_alone_true.py b/tests/user_commands/management/commands/leave_locale_alone_true.py
index 9861221e39..3100a2901b 100644
--- a/tests/user_commands/management/commands/leave_locale_alone_true.py
+++ b/tests/user_commands/management/commands/leave_locale_alone_true.py
@@ -4,7 +4,6 @@ from django.utils import translation
class Command(BaseCommand):
- can_import_settings = True
leave_locale_alone = True
def handle(self, *args, **options):