On Apr 11, 2:50 pm, Łukasz Rekucki <lreku...@gmail.com> wrote:
 > As for the error, it's quite a puzzle. If update() tries to iterate
> thru value, it means it's a non-empty sequence that's not a subclass
> of dict, right? Did you manage to track what type of value it is?
> There must be a bug somewhere else too.

When you iterate through a Context instance, you are iterating through
the dictionaries in the context:
In [1]: from django.template import Context
In [2]: c = Context()
In [3]: for d in c:
   ...:     print d
{}
In [4]: c.update({'fuu': 'bar'})
Out[4]: {'fuu': 'bar'}
In [5]: for d in c:
    print d
{'fuu': 'bar'}
{}

There is some discussion at https://code.djangoproject.com/ticket/17229,
and the core problem is that you really should not set a context
instance as one of the context dictionaries. However this is done in
many places in our code base, and I suspect user code does this, too.

At this point it might make sense to just revert the commit and then
investigate what to do. I see two ways forward: either disallow
context instances completely, or flatten the context instance to a
Python dict and use that as the base dictionary. So, something like:
is isinstance(value, Context):
    value = flatten_context_to_dict(value)
else:
    value = {}
value.update(builtins)
self._dicts=[value]

The latter option seems better - it does not risk breaking user code.

 - Anssi

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

Reply via email to