Opened 100 minutes ago

Last modified 99 seconds ago

#36909 new Bug

Avoid using context.request directly

Reported by: Jake Howard Owned by:
Component: Template system Version: 5.1
Severity: Normal Keywords:
Cc: jaffar Khan Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The RequestContext subclass sets context.request to the current request object. This attribute isn't available when Context is used, or when something context-looking is used instead. For example, the new querystring tag accesses context.request, making it incompatible in some cases.

I'd suggest that uses of context.request directly be replaced with context["request"], and that RequestContext automatically add request to its own context if it's not there already. It might also be worth renaming the attribute to _request to hint it shouldn't be used externally.

This likely only occurs when template context is being incorrectly handled, but it's likely worth improving regardless.

Change History (1)

comment:1 by jaffar Khan, 99 seconds ago

Cc: jaffar Khan added

Like to work on it if accepted.

Note: See TracTickets for help on using tickets.
Back to Top