Improve WSGI ugprade and include the virtualenv Python paths.

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

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.

Summary ID
Improve WSGI ugprade and include the virtualenv Python paths.
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.
a203bf40b78d80b76a289e162e0c61c696394f87
Description From Last Updated

indentation is not a multiple of 4 Column: 19 Error code: E111

reviewbotreviewbot

over-indented Column: 19 Error code: E117

reviewbotreviewbot

inline comment should start with '# ' Column: 40 Error code: E262

reviewbotreviewbot

at least two spaces before inline comment Column: 40 Error code: E261

reviewbotreviewbot

at least two spaces before inline comment Column: 40 Error code: E261

reviewbotreviewbot
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

chipx86
Review request changed
Change Summary:
  • Fixed a (harmless) indentation issue in some code.
  • Fixed a space on the wrong side of a #.
Commits:
Summary ID
Improve WSGI ugprade and include the virtualenv Python paths.
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.
3122e69af9be5e0c4c26d042cfb18a841137cbce
Improve WSGI ugprade and include the virtualenv Python paths.
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.
a203bf40b78d80b76a289e162e0c61c696394f87

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-5.0.x (94ada7e)