Hi Florian, thanks for your reply. I clearly didn't express myself properly, so let me try again with a simple example.
Suppose you are dealing with a detail view, whose context has an "object" key that refers to the object being displayed. Then, in the rendered template, you might have an inclusion tag that defines another context with an "object" key that refers to a different object (maybe one related to the "main" one). I don't see this as a bug, otherwise every tag should be aware of all the views (contexts and templates) where it is going to be used. Sure enough, if the tag takes the context, it is its responsibility to push and pop from the stack, but that's not what I was talking about. The fact is that when the test client gets a page, for every template that gets rendered, the store_rendered_templates is called through a signal and the context appended to the ContextList. This list is then flattened when you try to get an item from one of the context, and if you have multiple context with the same key, the first one rendered will be the one that you get, given the current implementation of ContextList.__getitem__. Hope that clears it up: ContextList is a list of dictionaries and I think it's not safe to assume that there are no overlapping keys - and probably it was already a knows "issue" since the keys method returns a set. Let me know if I completely missed something else, Germano On Monday, September 15, 2014 6:35:23 PM UTC+2, Florian Apolloner wrote: > > On Monday, September 15, 2014 3:24:19 PM UTC+2, germano guerrini wrote: >> >> I'd like to bump this. While there might be better solutions, I think the >> issue is not so wacky after all. >> > > To be honest, I don't see an issue here at all. What the view returns > should end up in the template. If tags/whatever in your template override > variables at will that's a bug in your application imo. Also your code > example fails to show where the key is overridden -- ie an include wouldn't > override cause the stack is popped after the include. Do you have a > concrete example causing this "issue"? > > Cheers, > Florian > -- You received this message because you are subscribed to the Google Groups "Django developers" 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]. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/93700e14-5cf0-45dc-8014-00810257a693%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
