#28001: Investigate/update comment about context popping in ForNode.render()
-------------------------------------+-------------------------------------
Reporter: Baptiste Mispelon | Owner: kapil
Type: | garg
Cleanup/optimization | Status: assigned
Component: Template system | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by kapil garg):
The reason admin tests were failing because 'forms/widgets/attrs.html'
uses 2 variables in for loop which implies that those variables are pushed
onto stack.
admin's 'split_datetime.html' template uses 'with' tag to push extra
content to context which is 'widget = widget.subwidgets.0' for date and
'widget = widget.subwidgets.1' for time.
Note here that now the context has a different variable with name
'widget'.
This calls 'attrs.html' after inclusions of 'text.html and input.html' and
'attrs.html' pushes its variables onto the context.
Now when "with" tag exits it pops the context which just pops "attrs.html"
variables and the 'widget' variable is still there which was used as a
local context.
When 'split_datetime.html' calls second 'with' node it gets the previous
'with' node's widget variable which has no 'subwidgets' and thus ends in
being widget value to None.
A None value is passed on and the next include tag in 'with' node try to
get a 'None' Template
So the final conclusion is : Whatever goes onto the context gets popped
out when its of no use and thus we need that line of code.
--
Ticket URL: <https://code.djangoproject.com/ticket/28001#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.b778f327bd01695a8cadeb19f2d0a17f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.