Changes between Initial Version and Version 1 of Ticket #23516, comment 3


Ignore:
Timestamp:
Sep 18, 2014, 7:21:15 PM (10 years ago)
Author:
Duncan Parkes

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #23516, comment 3

    initial v1  
    1010you'll see failures in both 1.6 and 1.7.
    1111
    12 The problem is that `IfChangedNode` stores what it looked like last time in the context by setting it as `state_frame[self]`. We were only getting the right thing in 1.6 because it was using `ConstantIncludeNode`, which calls `get_template` in its `__init__()`. With a normal `IncludeNode`, which is all there is in 1.7, `get_template` is called in `render()` causing a new `IfChangedNode` object. When the new `IfChangedNode` is looked up in as `state_frame[self]` it's not the same `self`!
     12The problem is that `IfChangedNode` stores what it looked like last time in the context by setting it as `state_frame[self]`. We were only getting the right thing in 1.6 because it was using `ConstantIncludeNode`, which calls `get_template` in its `__init__()`. With a normal `IncludeNode`, which is all there is in 1.7, `get_template` is called in `render()` causing a new `IfChangedNode` object. When the new `IfChangedNode` is looked up as `state_frame[self]` it's not the same `self`!
    1313
    1414Now I understand the problem, but I'm still not sure I have a solution. Perhaps `IfChangedNode` could be made to produce the same object rather than a new copy under the right circumstances, or perhaps we should store the previous version to compare to in `state_frame` using something other than `self` as the key.
Back to Top