Use call_command to invoke loaddata.

Review Request #5356 — Created Jan. 30, 2014 and submitted

Information

Review Board
release-1.7.x

Reviewers

Use call_command to invoke loaddata.

When triggering loaddata from rb-site, we were using an old method of invoking
the command which wouldn't set up default values for options. This change
updates us to use call_command() instead of handle()

Smoke tested rb-site install.

chipx86
  1. I'm very skeptical about the setup in that bug report.

    This code triggering the loaddata is ancient and will never be invoked on any new install. All that code exists solely for very old installs, and we should probably remove it all actually, since it was the migration path for pre-Django Evolution databases.

    He may be running rb-site install, but it's not a new database. To trigger this logic, the database must:

    1) Exist and be populated.
    2) Be pre-Django Evolution, or post but wiped of Evolution versioning data, or be pre-parent diffs.

    I suspect it's an existing database that was wiped.

    All that said, we shouldn't be failing. However, I recognize the problem, since I hit this in Djblets recently with Django Evolution.

    The real problem is that we're calling handle() ourselves, which is just wrong now in modern Djangos. The reason is that handle() won't set up the default options defined in the Command.

    What we need to do is change this to be:

    call_command('loaddata', '<path>', verbosity=0)
    
  2. 
      
david
chipx86
  1. Ship It!

  2. 
      
david
Review request changed
Status:
Completed