#24969: Backwards compatibility for optparse in management commands broken for
overrides.
-------------------------------+--------------------
Reporter: paul-butcher | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
Since this change:
https://github.com/django/django/commit/856863860352aa1f0288e6c9168a0e423c4f5184
The built-in options are always added, regardless of what is in
option_list for the Command.
Management commands that, in previous versions, overrode or replaced items
in the default option_list now raise an OptionConflictError on invocation.
This was noticed using Lettuce, (http://lettuce.it/), where invocation,
thus:
{{{$ python manage.py harvest}}}
gives the following response
{{{optparse.OptionConflictError: option -v/--verbosity: conflicting option
string(s): -v, --verbosity}}}
The `harvest` management command replaces the verbosity option, by
removing it from the option_list, thus:
{{{
class Command(BaseCommand):
help = u'Run lettuce tests all along installed apps'
args = '[PATH to feature file or folder]'
requires_model_validation = False
option_list = BaseCommand.option_list[1:] + (
make_option('-v', '--verbosity', action='store', dest='verbosity',
default='4',
type='choice', choices=map(str, range(5)),
help='Verbosity level; 0=no output, 1=only dots, 2=only
scenario names, 3=colorless output, 4=normal output (colorful)'),
...
}}}
Lettuce has a its [https://github.com/gabrielfalcao/lettuce/issues/480 own
corresponding version of this issue].
In earlier versions of Django, verbosity was the first item in
BaseCommand.option_list, so was discarded and replaced by the result of
make_option above.
In the current version, BaseCommand.option_list is no longer a collection
of defaults, and its former content is now mandatory and added
independently.
This problem does not necessarily arise using argparse, as the derived
class has greater control by overriding `add_arguments`
--
Ticket URL: <https://code.djangoproject.com/ticket/24969>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/055.63363cea0593b89c277d0f4a7e3ee8ee%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.