Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #13760 -- Cleaned up unnecessary default option handling in a b…

…unch of management commands. Thanks to Paul McMillan for the report and to adamv and Claude Paroz for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17028 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 59c051d1707ec1c32256193221b6ee2e3e533be5 1 parent adf51b0
@jphalip jphalip authored
View
2  django/core/management/commands/createcachetable.py
@@ -18,7 +18,7 @@ class Command(LabelCommand):
requires_model_validation = False
def handle_label(self, tablename, **options):
- alias = options.get('database', DEFAULT_DB_ALIAS)
+ alias = options.get('database')
connection = connections[alias]
fields = (
# "key" is a reserved word in MySQL, so use "cache_key" instead.
View
2  django/core/management/commands/dbshell.py
@@ -16,7 +16,7 @@ class Command(BaseCommand):
requires_model_validation = False
def handle(self, **options):
- connection = connections[options.get('database', DEFAULT_DB_ALIAS)]
+ connection = connections[options.get('database')]
try:
connection.client.runshell()
except OSError:
View
14 django/core/management/commands/dumpdata.py
@@ -30,13 +30,13 @@ class Command(BaseCommand):
def handle(self, *app_labels, **options):
from django.db.models import get_app, get_apps, get_model
- format = options.get('format','json')
- indent = options.get('indent',None)
- using = options.get('database', DEFAULT_DB_ALIAS)
- excludes = options.get('exclude',[])
- show_traceback = options.get('traceback', False)
- use_natural_keys = options.get('use_natural_keys', False)
- use_base_manager = options.get('use_base_manager', False)
+ format = options.get('format')
+ indent = options.get('indent')
+ using = options.get('database')
+ excludes = options.get('exclude')
+ show_traceback = options.get('traceback')
+ use_natural_keys = options.get('use_natural_keys')
+ use_base_manager = options.get('use_base_manager')
excluded_apps = set()
excluded_models = set()
View
4 django/core/management/commands/flush.py
@@ -23,9 +23,9 @@ class Command(NoArgsCommand):
're-executed, and the initial_data fixture will be re-installed.')
def handle_noargs(self, **options):
- db = options.get('database', DEFAULT_DB_ALIAS)
+ db = options.get('database')
connection = connections[db]
- verbosity = int(options.get('verbosity', 1))
+ verbosity = int(options.get('verbosity'))
interactive = options.get('interactive')
self.style = no_style()
View
2  django/core/management/commands/inspectdb.py
@@ -25,7 +25,7 @@ def handle_noargs(self, **options):
raise CommandError("Database inspection isn't supported for the currently selected database backend.")
def handle_inspection(self, options):
- connection = connections[options.get('database', DEFAULT_DB_ALIAS)]
+ connection = connections[options.get('database')]
table2model = lambda table_name: table_name.title().replace('_', '').replace(' ', '').replace('-', '')
View
6 django/core/management/commands/loaddata.py
@@ -34,13 +34,13 @@ class Command(BaseCommand):
)
def handle(self, *fixture_labels, **options):
- using = options.get('database', DEFAULT_DB_ALIAS)
+ using = options.get('database')
connection = connections[using]
self.style = no_style()
- verbosity = int(options.get('verbosity', 1))
- show_traceback = options.get('traceback', False)
+ verbosity = int(options.get('verbosity'))
+ show_traceback = options.get('traceback')
# commit is a stealth option - it isn't really useful as
# a command line option, but it can be useful when invoking
View
2  django/core/management/commands/runserver.py
@@ -139,4 +139,4 @@ def get_handler(self, *args, **options):
Serves admin media like old-school (deprecation pending).
"""
handler = super(Command, self).get_handler(*args, **options)
- return AdminMediaHandler(handler, options.get('admin_media_path', ''))
+ return AdminMediaHandler(handler, options.get('admin_media_path'))
View
2  django/core/management/commands/sql.py
@@ -16,4 +16,4 @@ class Command(AppCommand):
output_transaction = True
def handle_app(self, app, **options):
- return u'\n'.join(sql_create(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')
+ return u'\n'.join(sql_create(app, self.style, connections[options.get('database')])).encode('utf-8')
View
2  django/core/management/commands/sqlall.py
@@ -16,4 +16,4 @@ class Command(AppCommand):
output_transaction = True
def handle_app(self, app, **options):
- return u'\n'.join(sql_all(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')
+ return u'\n'.join(sql_all(app, self.style, connections[options.get('database')])).encode('utf-8')
View
2  django/core/management/commands/sqlclear.py
@@ -16,4 +16,4 @@ class Command(AppCommand):
output_transaction = True
def handle_app(self, app, **options):
- return u'\n'.join(sql_delete(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')
+ return u'\n'.join(sql_delete(app, self.style, connections[options.get('database')])).encode('utf-8')
View
2  django/core/management/commands/sqlcustom.py
@@ -16,4 +16,4 @@ class Command(AppCommand):
output_transaction = True
def handle_app(self, app, **options):
- return u'\n'.join(sql_custom(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')
+ return u'\n'.join(sql_custom(app, self.style, connections[options.get('database')])).encode('utf-8')
View
2  django/core/management/commands/sqlflush.py
@@ -16,4 +16,4 @@ class Command(NoArgsCommand):
output_transaction = True
def handle_noargs(self, **options):
- return u'\n'.join(sql_flush(self.style, connections[options.get('database', DEFAULT_DB_ALIAS)], only_django=True)).encode('utf-8')
+ return u'\n'.join(sql_flush(self.style, connections[options.get('database')], only_django=True)).encode('utf-8')
View
2  django/core/management/commands/sqlindexes.py
@@ -17,4 +17,4 @@ class Command(AppCommand):
output_transaction = True
def handle_app(self, app, **options):
- return u'\n'.join(sql_indexes(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')
+ return u'\n'.join(sql_indexes(app, self.style, connections[options.get('database')])).encode('utf-8')
View
2  django/core/management/commands/sqlreset.py
@@ -17,4 +17,4 @@ class Command(AppCommand):
output_transaction = True
def handle_app(self, app, **options):
- return u'\n'.join(sql_reset(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')
+ return u'\n'.join(sql_reset(app, self.style, connections[options.get('database')])).encode('utf-8')
View
2  django/core/management/commands/sqlsequencereset.py
@@ -16,5 +16,5 @@ class Command(AppCommand):
output_transaction = True
def handle_app(self, app, **options):
- connection = connections[options.get('database', DEFAULT_DB_ALIAS)]
+ connection = connections[options.get('database')]
return u'\n'.join(connection.ops.sequence_reset_sql(self.style, models.get_models(app, include_auto_created=True))).encode('utf-8')
View
6 django/core/management/commands/syncdb.py
@@ -22,9 +22,9 @@ class Command(NoArgsCommand):
def handle_noargs(self, **options):
- verbosity = int(options.get('verbosity', 1))
+ verbosity = int(options.get('verbosity'))
interactive = options.get('interactive')
- show_traceback = options.get('traceback', False)
+ show_traceback = options.get('traceback')
# Stealth option -- 'load_initial_data' is used by the testing setup
# process to disable initial fixture loading.
@@ -51,7 +51,7 @@ def handle_noargs(self, **options):
if not msg.startswith('No module named') or 'management' not in msg:
raise
- db = options.get('database', DEFAULT_DB_ALIAS)
+ db = options.get('database')
connection = connections[db]
cursor = connection.cursor()
View
4 django/core/management/commands/test.py
@@ -46,9 +46,7 @@ def handle(self, *test_labels, **options):
from django.test.utils import get_runner
TestRunner = get_runner(settings, options.get('testrunner'))
- options['verbosity'] = int(options.get('verbosity', 1))
- options.setdefault('interactive', True)
- options.setdefault('failfast', False)
+ options['verbosity'] = int(options.get('verbosity'))
test_runner = TestRunner(**options)
failures = test_runner.run_tests(test_labels)
View
4 django/core/management/commands/testserver.py
@@ -21,8 +21,8 @@ def handle(self, *fixture_labels, **options):
from django.core.management import call_command
from django.db import connection
- verbosity = int(options.get('verbosity', 1))
- interactive = options.get('interactive', True)
+ verbosity = int(options.get('verbosity'))
+ interactive = options.get('interactive')
addrport = options.get('addrport')
# Create a test database.
Please sign in to comment.
Something went wrong with that request. Please try again.