Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#17799 closed Bug (fixed)

Default parameters in syncdb.Command().Execute()

Reported by: kacah222@… Owned by: nobody
Component: Core (Management commands) Version: 1.4-beta-1
Severity: Normal Keywords: syncdb
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Trying to run syncdb.Command().Execute() command there is an error

TypeError: int() argument must be a string or a number, not 'NoneType'

Reason: no default values specified in syncdb.handle_noargs

Fix in attach.

Attachments (2)

syncdb.patch (818 bytes) - added by kacah222@… 3 years ago.
17799-2.diff (1.2 KB) - added by claudep 3 years ago.
Doc updated with note about execute

Download all attachments as: .zip

Change History (7)

Changed 3 years ago by kacah222@…

comment:1 Changed 3 years ago by ramiro

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 3 years ago by ramiro

  • Triage Stage changed from Accepted to Design decision needed

comment:3 Changed 3 years ago by claudep

I suddenly realized that call_command was working around this by picking defaults from klass.option_list.

    # Grab out a list of defaults from the options. optparse does this for us
    # when the script runs from the command line, but since call_command can
    # be called programatically, we need to simulate the loading and handling
    # of defaults (see #10080 for details).

Either we stick with the comment in call_command (and specifically add in the docs that execute should not be called directly):

This is the primary API you should use for calling specific commands.

Or we move the defaults value grabbing from call_command to execute (conditionally only when it is not run from command line).

This might be the real design decision to make.

Changed 3 years ago by claudep

Doc updated with note about execute

comment:4 Changed 3 years ago by carljm

  • Resolution set to fixed
  • Status changed from new to closed

In [17629]:

Fixed #17799 - Documented that the execute() method of a management command is not suitable for calling the command from code; call_command should be used instead. Thanks kacah222 for the report and claudep for the patch.

comment:5 Changed 3 years ago by ramiro

In [17678]:

Fixed #17820 -- Fixed more occurrences of redundant handling of management commands options.

They had been missen in the first attempts or had been introduced afterwards.

Refs #13760, #10080, #17799.

Note: See TracTickets for help on using tickets.
Back to Top