Add support for django 5.2 / Python 3.12 and upper - #36
Open
yakky wants to merge 25 commits into
Open
Conversation
- Drop MiddlewareMixin in favour of a plain new-style middleware so that set_urlconf(None) is guaranteed via try/finally even when a BaseException (SystemExit, KeyboardInterrupt, …) escapes Django's convert_exception_to_response wrapper, which only catches Exception. - Move reload_urlconf() before set_urlconf(urlconf) so that any set_urlconf call that reload_urlconf() may issue internally cannot override the site-specific value we are about to set. - Update tests: replace direct process_request/process_response calls with the __call__ contract; add test_urlconf_restored_after_exception to assert the try/finally guarantee against BaseException.
- tox.ini: envlist now py{311,312,313}-django{42,52}-cms{311}; remove
django32/41/cms39 deps; add django52 dep
- setup.cfg: python_requires >=3.11; classifiers updated to
Django 4.2/5.0/5.1/5.2 and Python 3.11/3.12/3.13
- .github/workflows/test.yml: matrix updated to Python 3.11/3.12/3.13,
Django 42/52, CMS 311; py313+django42 marked continue-on-error;
action versions bumped to v4/v5
- .github/workflows/lint.yml: Python bumped to 3.12; action versions
bumped to v4/v5
- pyproject.toml: black and ruff target-version updated to py311
- requirements-test.txt: remove mock, nose, django-nose, flake8 (dead
packages replaced by stdlib unittest.mock and ruff)
- cms_helper.py: rename MIDDLEWARE_CLASSES to MIDDLEWARE (removed in
Django 2.0)
Travis CI and the old GitLab CI config referenced Python 2.7/3.5-3.8 and Django 1.x/2.x. GitHub Actions is the active CI.
Travis CI and the old GitLab CI config referenced Python 2.7/3.5-3.8 and Django 1.x/2.x. GitHub Actions is the active CI.
MIDDLEWARE_CLASSES was ignored by Django since 2.0, so app_helper was supplying the full default middleware stack. Renaming it to MIDDLEWARE overrode that default with only the two multisite entries, dropping the session/auth/messages middleware required by Django admin. Since all tests instantiate CMSMultiSiteMiddleware directly (never via Django's WSGI handler), this setting has always been dead configuration. Remove it and let app_helper manage the full middleware stack.
Replace the protoroto GitHub zip URL in tox.ini and the django-multisite install_requires entry in setup.cfg with the django-multisite2 PyPI package. The multisite Python module name is unchanged.
django-multisite2 no longer exports `checks` from multisite.__init__; its system-check registration was moved into AppConfig.ready().
Django's built-in check_site_id raises sites.E101 because SiteID from django-multisite2 is a threading.local subclass that is not an int subclass, so int(SITE_ID) can fail at check time before any request sets the active site. Add AppConfig.ready() that removes the built-in check and registers a replacement which passes for both plain int and SiteID instances, matching the approach the original django-multisite used in checks.py.
…ctly `from django.core.checks import registry` resolves to the submodule django/core/checks/registry.py, not the CheckRegistry instance, because Python prefers the submodule when a package attribute and a submodule share the same name. Import the instance via its own module path instead.
…ltisite2 v2 Chain DynamicSiteMiddleware and CMSMultiSiteMiddleware via __call__ in CMSMultiSiteMiddlewareAliasTest._get_urlconf_during_request, and update the Http404 assertion to call the middleware directly instead of via the removed process_request method.
…tics django-multisite2 changes two things that broke the alias tests: 1. redirect_to_canonical defaults to True (was False in original package). Non-redirect aliases now need explicit redirect_to_canonical=False. 2. DynamicSiteMiddleware.__call__ only calls get_response when redirect_to_canonical() returns None — i.e. for canonical aliases (is_canonical=1) or redirect_to_canonical=False aliases. For all other cases it short-circuits with a redirect or 404 without ever calling the next handler. Fix: create canonical Alias rows (is_canonical=1) for the main domains so DynamicSiteMiddleware calls through; set redirect_to_canonical=False on the pass-through alias rows; test only the cases where get_response is reached.
…gnal django-multisite2 connects post_save_site_created to the Site model so a canonical Alias (is_canonical=1) is created automatically whenever a Site is saved. Manually creating the same row causes a unique-constraint ValidationError. Remove the two explicit canonical Alias.objects.create calls; only the non-canonical aliases need to be created by the test.
Use GITHUB_TOKEN (not COVERALLS_REPO_TOKEN) for coveralls-python's native GitHub Actions integration. Add || true so a coveralls API error never fails a green test run.
- actions/checkout v4 → v7 - actions/setup-python v5 → v6 - actions/cache v4 → v5 - codecov/codecov-action v4 → v7 Also fix the pip cache key which referenced matrix.toxenv (undefined), causing all matrix jobs to share the same empty cache slot.
- README: replace all django-multisite (ecometrica) refs with django-multisite2 - README: update supported versions to Django 4.2/5.2, django CMS 3.11 - README: replace deprecated MIDDLEWARE_CLASSES with MIDDLEWARE - README: replace Travis CI badge with GitHub Actions badge; drop CodeClimate badge - setup.cfg: update description; drop EOL Django 5.0/5.1 classifiers - CONTRIBUTING: update tox example to current Python/Django/CMS versions
….cfg/setup.py - Move all [metadata] and [options] to [project] table (PEP 621) - Version and readme remain dynamic via [tool.setuptools.dynamic] - Bump setuptools build requirement to >=61.0 (required for dynamic metadata) - Drop setup.py stub (superseded by pyproject.toml) - Drop setup.cfg
- Move config from .bumpversion.cfg to [tool.bumpversion] in pyproject.toml - Delete .bumpversion.cfg - pre_label values: dev → b → rc → final (drops unused alpha stage) - Workflow 1: bump pre_label ×3 walks dev→b→rc→release - Workflow 2: bump --new-version X.Y.Z jumps dev→release directly - tasks.py: bumpversion → bump-my-version bump; --list dropped; --message → --commit-message - tox.ini: add bump-my-version to pypi-description/release env deps - CONTRIBUTING: document both pre-release workflows; fix "bumpversion" reference
Member
|
LGTM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Update codebase to support django 4.2/5.2 only, and limit support to django CMS 3.11
Switch to new style middleware for more robustness and limit thread safety issues
Update tooling for a more up-to-date layout