Author: lukeplant
Date: 2010-09-07 15:45:48 -0500 (Tue, 07 Sep 2010)
New Revision: 13693
Modified:
django/branches/releases/1.2.X/
django/branches/releases/1.2.X/django/template/defaulttags.py
django/branches/releases/1.2.X/tests/regressiontests/templates/tests.py
Log:
[1.2.X] Fixed #13414 - QuerySet API ref wrong sql equivalent in __year lookup
example
Thanks to idle for report and patch
Backport of [13690] from trunk.
Property changes on: django/branches/releases/1.2.X
___________________________________________________________________
Name: svnmerge-integrated
-
/django/trunk:1-13360,13434,13480,13574,13600,13638,13652,13664,13666,13668,13680,13683,13685,13687-13688
+
/django/trunk:1-13360,13434,13480,13574,13600,13638,13652,13664,13666,13668,13680,13683,13685,13687-13688,13690
Modified: django/branches/releases/1.2.X/django/template/defaulttags.py
===================================================================
--- django/branches/releases/1.2.X/django/template/defaulttags.py
2010-09-07 20:43:19 UTC (rev 13692)
+++ django/branches/releases/1.2.X/django/template/defaulttags.py
2010-09-07 20:45:48 UTC (rev 13693)
@@ -157,15 +157,22 @@
loop_dict['first'] = (i == 0)
loop_dict['last'] = (i == len_values - 1)
+ pop_context = False
if unpack:
# If there are multiple loop variables, unpack the item into
# them.
- context.update(dict(zip(self.loopvars, item)))
+ try:
+ unpacked_vars = dict(zip(self.loopvars, item))
+ except TypeError:
+ pass
+ else:
+ pop_context = True
+ context.update(unpacked_vars)
else:
context[self.loopvars[0]] = item
for node in self.nodelist_loop:
nodelist.append(node.render(context))
- if unpack:
+ if pop_context:
# The loop variables were pushed on to the context so pop them
# off again. This is necessary because the tag lets the length
# of loopvars differ to the length of each set of items and we
Modified:
django/branches/releases/1.2.X/tests/regressiontests/templates/tests.py
===================================================================
--- django/branches/releases/1.2.X/tests/regressiontests/templates/tests.py
2010-09-07 20:43:19 UTC (rev 13692)
+++ django/branches/releases/1.2.X/tests/regressiontests/templates/tests.py
2010-09-07 20:45:48 UTC (rev 13693)
@@ -701,6 +701,7 @@
'for-tag-unpack11': ("{% for x,y,z in items %}{{ x }}:{{ y }},{{ z
}}/{% endfor %}", {"items": (('one', 1), ('two', 2))}, ("one:1,/two:2,/",
"one:1,INVALID/two:2,INVALID/")),
'for-tag-unpack12': ("{% for x,y,z in items %}{{ x }}:{{ y }},{{ z
}}/{% endfor %}", {"items": (('one', 1, 'carrot'), ('two', 2))},
("one:1,carrot/two:2,/", "one:1,carrot/two:2,INVALID/")),
'for-tag-unpack13': ("{% for x,y,z in items %}{{ x }}:{{ y }},{{ z
}}/{% endfor %}", {"items": (('one', 1, 'carrot'), ('two', 2, 'cheese'))},
("one:1,carrot/two:2,cheese/", "one:1,carrot/two:2,cheese/")),
+ 'for-tag-unpack14': ("{% for x,y in items %}{{ x }}:{{ y }}/{%
endfor %}", {"items": (1, 2)}, (":/:/", "INVALID:INVALID/INVALID:INVALID/")),
'for-tag-empty01': ("{% for val in values %}{{ val }}{% empty
%}empty text{% endfor %}", {"values": [1, 2, 3]}, "123"),
'for-tag-empty02': ("{% for val in values %}{{ val }}{% empty
%}values array empty{% endfor %}", {"values": []}, "values array empty"),
'for-tag-empty03': ("{% for val in values %}{{ val }}{% empty
%}values array not found{% endfor %}", {}, "values array not found"),
--
You received this message because you are subscribed to the Google Groups
"Django updates" 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-updates?hl=en.