Update the extensions code to be compatible with Django 1.6 and higher.

Review Request #8707 — Created Feb. 2, 2017 and submitted

Information

Djblets
release-0.10.x
d9f2d73...

Reviewers

The extensions code, for many reasons, was not compatible with newer
versions of Django. We have to do a lot of manipulation of Django state
(template-related caches, model caches, installed apps, etc.) for
extensions, and this has all changed since Django 1.6.

This change adds support for manipulating all this in newer versions of
Django, and retains support for Django 1.6.

Along the way, some problems with how we were doing things were found.
Due probably to a bad merge at some point, much of the extension
initialization code was living in the media installation code and was
being called too late in the cycle. This didn't manifest as an obvious
problem on Django 1.6 (though it likely did result in apps not being
properly removed when an extension was disabled), but it was a major
problem on newer versions (which track apps and state more closely).
This code has been cleaned up and ordering has been fixed.

Models weren't being properly cleared from caches before, which wasn't a
big problem in practice but could in theory lead to
introspection-related problems. These caches are now properly cleared,
where possible.

We also now call the evolve command from Django Evolution more
correctly, ensuring compatibility not just with various versions of
Django but also with changes to the evolve command and its argument
list.

Unit tests have been added to check for all the cache-related changes,
model synchronization, and evolution operations.

Unit tests pass on Django 1.6 and 1.8 through 1.10.

Description From Last Updated

'Evolution' imported but unused

reviewbotreviewbot

'import_module' imported but unused

reviewbotreviewbot

'Evolution' imported but unused

reviewbotreviewbot

"Add" "setting wrapper" ?

brenniebrennie

"setting wrapper" ?

brenniebrennie

likewise, here?

brenniebrennie

while here, docstring?

brenniebrennie

Maybe put this into the else block so that it matches the return True? Or assign self.ref_counts[item] == 1 to …

daviddavid
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/extensions/test/evolve_tests/evolutions/__init__.py
        djblets/extensions/test/evolve_tests/models.py
        djblets/extensions/test/evolve_tests/evolutions/add_new_field.py
        djblets/extensions/manager.py
        djblets/extensions/test/templatetag_tests/templatetags/templatetag_tests.py
        djblets/extensions/tests.py
        djblets/extensions/test/model_tests/models.py
    
    Ignored Files:
        djblets/extensions/test/evolve_tests/__init__.py
        djblets/extensions/test/templatetag_tests/templatetags/__init__.py
        djblets/extensions/test/templatetag_tests/__init__.py
        djblets/extensions/test/model_tests/__init__.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/extensions/test/evolve_tests/evolutions/__init__.py
        djblets/extensions/test/evolve_tests/models.py
        djblets/extensions/test/evolve_tests/evolutions/add_new_field.py
        djblets/extensions/manager.py
        djblets/extensions/test/templatetag_tests/templatetags/templatetag_tests.py
        djblets/extensions/tests.py
        djblets/extensions/test/model_tests/models.py
    
    Ignored Files:
        djblets/extensions/test/evolve_tests/__init__.py
        djblets/extensions/test/templatetag_tests/templatetags/__init__.py
        djblets/extensions/test/templatetag_tests/__init__.py
        djblets/extensions/test/model_tests/__init__.py
    
    
  2. djblets/extensions/manager.py (Diff revision 1)
     
     
    Show all issues
     'Evolution' imported but unused
    
  3. djblets/extensions/tests.py (Diff revision 1)
     
     
    Show all issues
     'import_module' imported but unused
    
  4. djblets/extensions/tests.py (Diff revision 1)
     
     
    Show all issues
     'Evolution' imported but unused
    
  5. 
      
chipx86
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/extensions/test/evolve_tests/evolutions/__init__.py
        djblets/extensions/test/evolve_tests/models.py
        djblets/extensions/test/evolve_tests/evolutions/add_new_field.py
        djblets/extensions/manager.py
        djblets/extensions/test/templatetag_tests/templatetags/templatetag_tests.py
        djblets/extensions/tests.py
        djblets/extensions/test/model_tests/models.py
    
    Ignored Files:
        djblets/extensions/test/evolve_tests/__init__.py
        djblets/extensions/test/templatetag_tests/templatetags/__init__.py
        djblets/extensions/test/templatetag_tests/__init__.py
        djblets/extensions/test/model_tests/__init__.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/extensions/test/evolve_tests/evolutions/__init__.py
        djblets/extensions/test/evolve_tests/models.py
        djblets/extensions/test/evolve_tests/evolutions/add_new_field.py
        djblets/extensions/manager.py
        djblets/extensions/test/templatetag_tests/templatetags/templatetag_tests.py
        djblets/extensions/tests.py
        djblets/extensions/test/model_tests/models.py
    
    Ignored Files:
        djblets/extensions/test/evolve_tests/__init__.py
        djblets/extensions/test/templatetag_tests/templatetags/__init__.py
        djblets/extensions/test/templatetag_tests/__init__.py
        djblets/extensions/test/model_tests/__init__.py
    
    
  2. 
      
chipx86
  1. Hold off on this. I hit some regressions.

  2. 
      
brennie
  1. 
      
  2. djblets/extensions/manager.py (Diff revision 2)
     
     
    Show all issues

    "Add"
    "setting wrapper" ?

    1. It's actually adding to the setting (if not already in there).

  3. djblets/extensions/manager.py (Diff revision 2)
     
     
    Show all issues

    "setting wrapper" ?

  4. djblets/extensions/manager.py (Diff revision 2)
     
     
    Show all issues

    likewise, here?

  5. djblets/extensions/manager.py (Diff revision 2)
     
     
    Show all issues

    while here, docstring?

  6. 
      
chipx86
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/extensions/test/evolve_tests/evolutions/__init__.py
        djblets/extensions/test/evolve_tests/models.py
        djblets/extensions/test/evolve_tests/evolutions/add_new_field.py
        djblets/extensions/manager.py
        djblets/extensions/test/templatetag_tests/templatetags/templatetag_tests.py
        djblets/extensions/tests.py
        djblets/extensions/test/model_tests/models.py
    
    Ignored Files:
        djblets/extensions/test/evolve_tests/__init__.py
        djblets/extensions/test/templatetag_tests/templatetags/__init__.py
        djblets/extensions/test/templatetag_tests/__init__.py
        djblets/extensions/test/model_tests/__init__.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/extensions/test/evolve_tests/evolutions/__init__.py
        djblets/extensions/test/evolve_tests/models.py
        djblets/extensions/test/evolve_tests/evolutions/add_new_field.py
        djblets/extensions/manager.py
        djblets/extensions/test/templatetag_tests/templatetags/templatetag_tests.py
        djblets/extensions/tests.py
        djblets/extensions/test/model_tests/models.py
    
    Ignored Files:
        djblets/extensions/test/evolve_tests/__init__.py
        djblets/extensions/test/templatetag_tests/templatetags/__init__.py
        djblets/extensions/test/templatetag_tests/__init__.py
        djblets/extensions/test/model_tests/__init__.py
    
    
  2. 
      
david
  1. Whew!

  2. djblets/extensions/manager.py (Diff revision 3)
     
     
    Show all issues

    Maybe put this into the else block so that it matches the return True? Or assign self.ref_counts[item] == 1 to a variable and then test against it, and then return it?

    1. I'll do the former and add some docs.

  3. 
      
chipx86
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/extensions/test/evolve_tests/evolutions/__init__.py
        djblets/extensions/test/evolve_tests/models.py
        djblets/extensions/test/evolve_tests/evolutions/add_new_field.py
        djblets/extensions/manager.py
        djblets/extensions/test/templatetag_tests/templatetags/templatetag_tests.py
        djblets/extensions/tests.py
        djblets/extensions/test/model_tests/models.py
    
    Ignored Files:
        djblets/extensions/test/evolve_tests/__init__.py
        djblets/extensions/test/templatetag_tests/templatetags/__init__.py
        djblets/extensions/test/templatetag_tests/__init__.py
        djblets/extensions/test/model_tests/__init__.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/extensions/test/evolve_tests/evolutions/__init__.py
        djblets/extensions/test/evolve_tests/models.py
        djblets/extensions/test/evolve_tests/evolutions/add_new_field.py
        djblets/extensions/manager.py
        djblets/extensions/test/templatetag_tests/templatetags/templatetag_tests.py
        djblets/extensions/tests.py
        djblets/extensions/test/model_tests/models.py
    
    Ignored Files:
        djblets/extensions/test/evolve_tests/__init__.py
        djblets/extensions/test/templatetag_tests/templatetags/__init__.py
        djblets/extensions/test/templatetag_tests/__init__.py
        djblets/extensions/test/model_tests/__init__.py
    
    
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-0.10.x (94a5793)