Fix {% template_hook_point %} when using RequestContext.

Review Request #14155 — Created Sept. 11, 2024 and submitted — Latest diff uploaded

Information

Djblets
release-5.x

Reviewers

In the case of unit tests, we may be rendering some templates that
include {% template_hook_point %} without going through all our usual
context processor machinery. In this case, we can sometimes hit cases
where we're calling this tag with a RequestContext that does not
actually have request in the dict contents. This was causing some unit
test failures.

This change makes it so our template tag will check if we have a
RequestContext, and if so, get the request from the attribute instead
of trying to pull it out of the dict. This fixes the cases where unit
tests were crashing.

Ran tests in both Djblets and Review Board (the latter being where I
was hitting these issues).

Diff Revision 1 (Latest)

Commits

First Last Summary ID Author
Fix {% template_hook_point %} when using RequestContext.
In the case of unit tests, we may be rendering some templates that include `{% template_hook_point %}` without going through all our usual context processor machinery. In this case, we can sometimes hit cases where we're calling this tag with a `RequestContext` that does not actually have `request` in the dict contents. This was causing some unit test failures. This change makes it so our template tag will check if we have a `RequestContext`, and if so, get the request from the attribute instead of trying to pull it out of the dict. This fixes the cases where unit tests were crashing. Testing Done: Ran tests in both Djblets and Review Board (the latter being where I was hitting these issues).
71741e401f4e21aff2667fba8d0da3c8a91f8e57 David Trowbridge
djblets/extensions/templatetags/djblets_extensions.py
Loading...