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
- Django used to ship a backport of Python 2.7's
is no longer included. Since we are now 2.7+ only, we can use the
standard library version.
ModelFormneeds to define
- Models need to define
app_label, especially in the extension context
where the module is not listed in
ToolOptionsWidget.format_outputmethod was removed, seemingly
without explanation (despite being recommended as something that could
be overridden in the comments). Since we're completely overriding
rendermethod, this has been changed to just do what
- 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.
This is probably going to affect any table names. It'll be important to set a db_table if this causes them ...
This all becomes nicer with Unicode strings if we use import_module. The module name can be a Unicode string in ...
Have we ever hit this code path? Because __import__('.') just returns "Empty module name".
Can you alphabetize these?
This is probably going to affect any table names. It'll be important to set a
db_tableif 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 either
__import__-- it's only the
__import__that requires native strings, so
getattr()can use the string as provided:
... module = import_module(module_name) return getattr(module, class_path[-1])
Have we ever hit this code path? Because
__import__('.')just returns "Empty module name".
Revision 2 (+16 -19)