#13760: Management commands should not specify the default value twice
-----------------------------+----------------------------------------------
 Reporter:  PaulM            |       Owner:  nobody    
   Status:  new              |   Milestone:            
Component:  django-admin.py  |     Version:  1.2       
 Keywords:                   |       Stage:  Unreviewed
Has_patch:  0                |  
-----------------------------+----------------------------------------------
 Many of the management commands have a code pattern that seems likely to
 invite errors:

 In the base of the Command class, they define options, including default
 values like this:

 {{{
 class Command(BaseCommand):
     option_list = BaseCommand.option_list + (
         make_option('--format', default='json', dest='format',
             help='Specifies the output serialization format for
 fixtures.'),
 }}}

 Then later on in the handle method, they get the option value, specifying
 a new default value if the option is not found, like this:

 {{{
     def handle(self, *app_labels, **options):
         format = options.get('format','json')
 }}}

 This second default value is an error. Using optparse means that we are
 certain to receive a value for each option (it defaults to None). Using
 options.get() with a default value is redundant. Trying to get a non-
 existent option should throw an error, not return a default value.

 Most of the management commands need this cleanup.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/13760>
Django <http://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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to