Fix {% template_hook_point %} when using RequestContext.

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

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).

Summary ID
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
Description From Last Updated

I think we want to type variables only once (probably before the conditional). I've had type checkers yell at me …

chipx86chipx86
maubin
  1. Ship It!
  2. 
      
chipx86
  1. 
      
  2. Show all issues

    I think we want to type variables only once (probably before the conditional). I've had type checkers yell at me for trying to do it twice.

  3. 
      
david
Review request changed
Status:
Completed
Change Summary:
Pushed to release-5.x (aac7a30)