Improve options and compatibility when initializing Review Board.

Review Request #10536 — Created April 17, 2019 and submitted

Information

Review Board
release-4.0.x

Reviewers

This change aims to improve the initialization of Review Board (through
the initialize() method), to give callers more control over that
process, and to reduce the work needed by callers.

initialize() now has a few new arguments for controlling the
initialization process. Extensions can now be turned off for callers
that don't need them, as can some custom template support ({% url %}
tag on Django 1.6 and some template serial generation for caching).
Logging can also be turned off, in case the caller has set things up
already.

Callers no longer need to set the DJANGO_SETTINGS_MODULE environment
variable first. If not already set, initialize() will set this to
reviewboard.settings automatically.

We also already had some code that attempted to initialize Django (using
django.setup()), but it was doing this a bit later than we wanted. We
now try to do this earlier, before we import anything from Django. We
also only do it now if we've detected that Django isn't yet set up.

rbssh has been updated to take advantage of these changes as well,
removing all extension loading, template serial generation, and unwanted
logging setup (which is being overridden anyway) to minimize startup
time.

Unit tests pass on Python 2.7/Django 1.6 and Python 3.7/Django 1.11.

Manually tested rbssh with and without debug logging.

Summary ID
Improve options and compatibility when initializing Review Board.
This change aims to improve the initialization of Review Board (through the `initialize()` method), to give callers more control over that process, and to reduce the work needed by callers. `initialize()` now has a few new arguments for controlling the initialization process. Extensions can now be turned off for callers that don't need them, as can some custom template support (`{% url %}` tag on Django 1.6 and some template serial generation for caching). Logging can also be turned off, in case the caller has set things up already. Callers no longer need to set the `DJANGO_SETTINGS_MODULE` environment variable first. If not already set, `initialize()` will set this to `reviewboard.settings` automatically. We also already had some code that attempted to initialize Django (using `django.setup()`), but it was doing this a bit later than we wanted. We now try to do this earlier, before we import anything from Django. We also only do it now if we've detected that Django isn't yet set up. `rbssh` has been updated to take advantage of these changes as well, removing all extension loading, template serial generation, and unwanted logging setup (which is being overridden anyway) to minimize startup time.
6d0c1c7c54019fa340cb1fbedf0a747788b5129c
david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-4.0.x (8360e62)
Loading...