mirror of https://github.com/django/django.git
Fixed #13760 -- Cleaned up unnecessary default option handling in a bunch 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
This commit is contained in:
parent
adf51b0cb8
commit
59c051d170
|
@ -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.
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -25,7 +25,7 @@ class Command(NoArgsCommand):
|
|||
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('-', '')
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -139,4 +139,4 @@ class Command(BaseRunserverCommand):
|
|||
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'))
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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 @@ class Command(NoArgsCommand):
|
|||
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()
|
||||
|
||||
|
|
|
@ -46,9 +46,7 @@ class Command(BaseCommand):
|
|||
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)
|
||||
|
|
|
@ -21,8 +21,8 @@ class Command(BaseCommand):
|
|||
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.
|
||||
|
|
Loading…
Reference in New Issue