﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
21639	RenderContext should override __getitem__	Alex Hill	nobody	"From the comments for RenderContext:
  

> Name resolution fails if a variable is not found at the top of the RequestContext stack. Thus, variables are local to a specific template and don't affect the rendering of other templates as they would if they were stored in the normal template context.
  

In RenderContext, the methods `__iter__`, `get`, and `has_key` are overridden. `has_key` is called internally by `BaseContext.__contains__`, so ""in"" works as expected, but `get` is not similarly called by `__getitem__`, so using `get` and using indexing syntax give different results. It seems to me that that's an oversight, and to be consistent with the intention as stated in the comment, `__getitem__` should be overridden too.

Example of the wrong/inconsistent behaviour:

{{{
>>> from django.template.context import RenderContext
>>> c = RenderContext({'fruit': 'banana'})
>>> 'fruit' in c
True
>>> c.push()
{}
>>> 'fruit' in c
False
>>> c.get('fruit')
>>> c['fruit']
'banana'
}}}"	Bug	closed	Template system	dev	Normal	fixed			Accepted	1	0	0	1	1	0
