Improve WSGI ugprade and include the virtualenv Python paths.

Review Request #13148 — Created July 14, 2023 and submitted — Latest diff uploaded

Information

Review Board
release-5.0.x

Reviewers

This updates the generated htdocs/reviewboard.wsgi file to include the
virtualenv Python path, which will be used if a virtualenv is set up.
This is needed in order to make the reviewboard import work correctly.
The main reviewboard/wsgi.py will then proceed with full virtualenv
activation.

Existing copies of reviewboard.wsgi will be upgraded with the new
code. The upgrade logic has grown more complex in time, and as part of
this change, it's been overhauled to be more maintainable. We now try
to determine custom settings added to the script by admins and preserve
those, but otherwise rewrite the file to a completely custom version.

This mostly simplifies the upgrade logic, but the way we handle upgrades
does depend on what we're upgrading.

For older (pre-5.0.6) files, we now remove everything we've ever added
from the file and use the rest to determine any custom settings from the
administrators, which we'll preserve.

For 5.0.6+ installs, we look explicitly for a commented region
containing custom settings (wrapped by # BEGIN CUSTOM SETTINGS and
# END CUSTOM SETTINGS).

We then output the final script based on the template file.

Along with these changes, we no longer import the imp module in
rb-site. This isn't available on newer installs, and our usage of it
wasn't really necessary.

Tested generating a new site and verifying the resulting script worked
and resulted in an activated virtualenv with Review Board and Django.

Tested upgrading some versions of older and custom-altered
reviewboard.wsgi files.

Unit tests pass.

Commits

Files

    Loading...