#18555: Calling management commands programmatically without options no longer
works [regression]
--------------------------------------------+--------------------
     Reporter:  marcelcoding@…              |      Owner:  nobody
         Type:  Bug                         |     Status:  new
    Component:  Core (Management commands)  |    Version:  master
     Severity:  Normal                      |   Keywords:
 Triage Stage:  Unreviewed                  |  Has patch:  0
Easy pickings:  0                           |      UI/UX:  0
--------------------------------------------+--------------------
 I apologize in case I'm doing this wrong from the very beginning, but for
 my application this looks like a relatively recent "cleanup" introduced a
 regression...

 In Django 1.3.1, I was able to call the syncdb command from my python
 application like this:

 {{{
 
django.core.management.commands.syncdb.Command().handle_noargs(interactive=False)
 }}}

 If I'm doing this with django on trunk, I get
 {{{
 File "/usr/local/lib/python2.7/dist-
 packages/django/core/management/commands/syncdb.py", line 28, in
 handle_noargs
     verbosity = int(options.get('verbosity'))
 TypeError: int() argument must be a string or a number, not 'NoneType'
 }}}

 This seems to be a direct result from the fixes for ticket #13760 and
 similar, where code like
 {{{
 int(options.get('verbosity', 1))
 }}}
 was replaced with:
 {{{
 int(options.get('verbosity'))
 }}}

 The reasoning behind these patches was that the getopt parsing already
 provides reasonable defaults for all options -- but this is only true for
 arguments provided by the command line and not when a handle or
 handle_noargs method is called directly.

 You can of course easily work around this problem by explicitly providing
 the options explicitely (in my case, I have to add verbosity=0 and
 database='default') -- but I wonder whether there is not a bunch of code
 out there that will break like mine did...

 I don't know what a good solution would be, specifying defaults twice (and
 possibly inconsistently) as previously is certainly not an option.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/18555>
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 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