On Apr 11, 8:10 am, "Wolfram Kriesing" <[EMAIL PROTECTED]>
wrote:
> The "add_data" adds the data to the context inside the render()
> function of the tag. Here lies the problem, the scope of the for loop
> gets destroyed when the for loop ends

Well, in a template context, that does make more sense to me, since
you don't really have advanced control structures to break the flow at
different points. In pure Python, it would be reasonable to set
something within a loop, then break out and use that value elsewhere.
In a template, however, the entire loop is iterated regardless, and
you'd be setting the value on every iteration, so the last value is
the only one that would be available outside the loop anyway. In that
case, I think it would make more sense to just set that somewhere
outside the loop and avoid the mess.

That said, there might be other use cases for what you're describing,
but the only real way to go about it would be add some kind of
"parent" attribute to each context on the stack, but then there are
questions of what it points to. Is it the immediately previous context
or the top-most? Should there be a way of specifying how far up the
stack to go? Should each context on the stack be able to report what
position it's in? If this would be implemented, would there be a
safeguard to prevent template tags from swapping out one layer of the
stack with another?

All in all, it seems like the current behavior would be acceptable,
but like I said, there may be other use cases that haven't yet been
raised.

-Gul


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to