Update the extensions code to be compatible with Django 1.6 and higher.
Review Request #8707 — Created Feb. 2, 2017 and submitted
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 |
reviewbot | |
'import_module' imported but unused |
reviewbot | |
'Evolution' imported but unused |
reviewbot | |
"Add" "setting wrapper" ? |
brennie | |
"setting wrapper" ? |
brennie | |
likewise, here? |
brennie | |
while here, docstring? |
brennie | |
Maybe put this into the else block so that it matches the return True? Or assign self.ref_counts[item] == 1 to … |
david |
- Change Summary:
-
- Django Evolution is no longer a hard requirement for projects using extensions.
- Fixed some unused imports.
- Commit:
-
2b23ff250b320c7a31510e45f45e025f7d9c051e40f08d999bd9caa490c1a9414437cdffb327f375
- Diff:
-
Revision 2 (+496 -145)
-
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
- Change Summary:
-
- Added/refined some docstrings.
- Reworked the model clearing logic:
- Some caches are now untouched, as is
sys.modules
. We need to leave the model modules around long-term or things can break. Some of this may be revisited down the road, particularly for Django > 1.6. - Fixed a problem where an app label without models (like
rbpowerpack.hostingsvcs
) could conflict with an app label with models (reviewboard.hostingsvcs
) and wipe out the model registrations when removed.
- Some caches are now untouched, as is
- Description:
-
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. ~ 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. - Commit:
-
40f08d999bd9caa490c1a9414437cdffb327f37567ab4f629bb1f29978f64c4053b193e48c0f957c
- Diff:
-
Revision 3 (+498 -146)
-
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
- Change Summary:
-
Added some docs and improved a return statement's position in a function.
- Commit:
-
67ab4f629bb1f29978f64c4053b193e48c0f957cd9f2d73dd6ca6b19996cebf80f66ce4accb78df8
- Diff:
-
Revision 4 (+502 -146)
-
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