Update Review Bot extension for Django 1.11 changes.
Review Request #10877 — Created Feb. 3, 2020 and submitted
This change updates the Review Bot extension to handle deprecated and
changed APIs for Django 1.11 and Python 3. These include:
- URL patterns are now defined as lists instead of using the old
patterns
object. - Django used to ship a backport of Python 2.7's
import_module
, which
is no longer included. Since we are now 2.7+ only, we can use the
standard library version. ModelForm
needs to defineMeta.fields
.- Models need to define
app_label
, especially in the extension context
where the module is not listed inINSTALLED_APPS
. - The
ToolOptionsWidget.format_output
method was removed, seemingly
without explanation (despite being recommended as something that could
be overridden in the comments). Since we're completely overriding
the widget'srender
method, this has been changed to just do what
the oldformat_output
method did. - Python 3's
__import__
needs to use native strings rather than bytes.
Set up the Review Bot extension on my local devserver using the latest
Review Board release-4.0.x HEAD and Python 3, and connected a worker.
Configured an integration for jshint and published a review request. Saw
that Review Bot triggered the worker job, collected errors, and posted
them back to the review request.
Description | From | Last Updated |
---|---|---|
This is probably going to affect any table names. It'll be important to set a db_table if this causes them … |
chipx86 | |
This all becomes nicer with Unicode strings if we use import_module. The module name can be a Unicode string in … |
chipx86 | |
Have we ever hit this code path? Because __import__('.') just returns "Empty module name". |
chipx86 | |
Can you alphabetize these? |
chipx86 |
-
-
This is probably going to affect any table names. It'll be important to set a
db_table
if this causes them to differ at all between an old and a new database. -
This all becomes nicer with Unicode strings if we use
import_module
. The module name can be a Unicode string in eitherimport_module
or__import__
-- it's only thefromlist
attribute on__import__
that requires native strings, sogetattr()
can use the string as provided:... module = import_module(module_name) return getattr(module, class_path[-1])
-