Skip to content

fix: register theming context processor on CONTEXT_PROCESSORS for Verawood - #98

Merged
jignaciopm merged 1 commit into
masterfrom
fix/verawood-context-processor-registration
Sep 4, 2026
Merged

fix: register theming context processor on CONTEXT_PROCESSORS for Verawood#98
jignaciopm merged 1 commit into
masterfrom
fix/verawood-context-processor-registration

Conversation

@jignaciopm

@jignaciopm jignaciopm commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Description

From Verawood onwards, edx-platform builds its settings with the new Derived settings framework (openedx/envs/common.py). As part of that change, each template engine's context_processors is no longer a list but a Derived value:

TEMPLATES = [
    { 'NAME': 'django', ... 'context_processors': Derived(lambda settings: settings.CONTEXT_PROCESSORS) },
    { 'NAME': 'mako',   ... 'context_processors': Derived(lambda settings: settings.CONTEXT_PROCESSORS) },
]

plugin_settings() registered the theming context processor by mutating those entries directly:

settings.TEMPLATES[1]['OPTIONS']['context_processors'].append(eox_configuration_path)

On Verawood .append() / in run against a Derived object (which is not a list and not iterable), raising AttributeError/TypeError that was caught and only logged. The context processor was therefore never registered, leaving the theming template variable undefined and making every legacy Mako/Django page fail with:

AttributeError: 'Undefined' object has no attribute 'options'

Fix

Register the context processor on settings.CONTEXT_PROCESSORS instead. Both the Django and Mako engines derive their context_processors from this setting, so the change works across releases:

  • Earlier releases point each engine's context_processors at the same CONTEXT_PROCESSORS list, so appending to it reaches both engines.
  • Verawood and later resolve their Derived values to settings.CONTEXT_PROCESSORS when derive_settings() runs, picking up the appended processor.

A fallback is kept for releases that don't expose a CONTEXT_PROCESSORS setting (registers on each engine whose context_processors is still a plain list).

No support for earlier releases is dropped.

  • User roles impacted: Operator (theming on Verawood deployments).
  • Config changes: none required by operators; registration is automatic.

Testing instructions

  1. On a Verawood environment with eox-theming installed and a comprehensive theme enabled (e.g. bragi/css-runtime), load any legacy Mako page (for example /404 or the login page).

    • Before: HTTP 500, AttributeError: 'Undefined' object has no attribute 'options'.
    • After: the page renders and theming.options(...) resolves.
  2. Run the unit tests:

    make test-python
    # or, focused:
    DJANGO_SETTINGS_MODULE=eox_theming.settings.test pytest eox_theming/tests/test_settings.py

    New tests in eox_theming/tests/test_settings.py cover: registration via CONTEXT_PROCESSORS (Verawood/Derived), idempotency, the legacy shared-list path, and the no-CONTEXT_PROCESSORS fallback.

Additional information

  • Bumps version 10.1.010.1.1, updates CHANGELOG.md (Fixed) and the README compatibility notes (Verawood >= 10.1.1).
  • Adds a README note documenting the Verawood rename of _make_mako_template_dirsmake_mako_template_dirs (now in openedx.envs.common).
  • v10.1.0 declared Verawood support but only updated dependencies/CI; this PR fixes the actual runtime regression.

Tested in a remote environment

image

Checklist for Merge

  • Tested in a remote environment
  • Updated documentation
  • Rebased master/main
  • Squashed commits

@jignaciopm
jignaciopm requested a review from a team as a code owner September 4, 2026 01:10
…awood

From Verawood onwards, TEMPLATES[*]['OPTIONS']['context_processors'] are
Derived values instead of lists, so appending to them raised an
AttributeError that was silently swallowed. As a result the `theming`
context processor was never registered and every legacy Mako page failed
with "AttributeError: 'Undefined' object has no attribute 'options'".

Register the processor on CONTEXT_PROCESSORS instead, which both template
engines derive from. This keeps compatibility with earlier releases (where
both engines share the same CONTEXT_PROCESSORS list), adds a fallback for
releases without a CONTEXT_PROCESSORS setting, and adds unit tests covering
the registration paths.

Bump version to 10.1.1 and update CHANGELOG and README compatibility notes.
@jignaciopm
jignaciopm force-pushed the fix/verawood-context-processor-registration branch from ef00b0c to e582aa5 Compare September 4, 2026 01:16

@MaferMazu MaferMazu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. Thanks ✨

@jignaciopm
jignaciopm merged commit 37fe8ee into master Sep 4, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants