Update Review Bot extension for Django 1.11 changes.

Review Request #10877 — Created Feb. 3, 2020 and submitted

Information

ReviewBot
master
9579136...

Reviewers

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 define Meta.fields.
  • Models need to define app_label, especially in the extension context
    where the module is not listed in INSTALLED_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's render method, this has been changed to just do what
    the old format_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 …

chipx86chipx86

This all becomes nicer with Unicode strings if we use import_module. The module name can be a Unicode string in …

chipx86chipx86

Have we ever hit this code path? Because __import__('.') just returns "Empty module name".

chipx86chipx86

Can you alphabetize these?

chipx86chipx86
chipx86
  1. 
      
  2. extension/reviewbotext/models.py (Diff revision 1)
     
     

    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.

    1. This makes it use the same table name that was automatically assigned previously.

  3. extension/reviewbotext/widgets.py (Diff revision 1)
     
     
     
     
     
     
     
     
     
     

    This all becomes nicer with Unicode strings if we use import_module. The module name can be a Unicode string in either import_module or __import__ -- it's only the fromlist attribute on __import__ that requires native strings, so getattr() can use the string as provided:

    ...
    
    module = import_module(module_name)
    return getattr(module, class_path[-1])
    
  4. extension/reviewbotext/widgets.py (Diff revision 1)
     
     

    Have we ever hit this code path? Because __import__('.') just returns "Empty module name".

  5. 
      
david
chipx86
  1. 
      
  2. extension/reviewbotext/models.py (Diff revision 2)
     
     
     

    Can you alphabetize these?

  3. 
      
david
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to master (6cdc5c7)
Loading...