1
0
mirror of https://github.com/django/django.git synced 2025-10-31 01:25:32 +00:00

[py3] Fixed access to dict keys/values/items.

This commit is contained in:
Aymeric Augustin
2012-07-20 21:14:27 +02:00
parent fa3f0aa021
commit ee191715ea
64 changed files with 187 additions and 155 deletions

View File

@@ -961,7 +961,7 @@ def parse_bits(parser, bits, params, varargs, varkw, defaults,
kwarg = token_kwargs([bit], parser)
if kwarg:
# The kwarg was successfully extracted
param, value = kwarg.items()[0]
param, value = list(six.iteritems(kwarg))[0]
if param not in params and varkw is None:
# An unexpected keyword argument was supplied
raise TemplateSyntaxError(

View File

@@ -17,6 +17,7 @@ from django.template.defaultfilters import date
from django.utils.encoding import smart_unicode
from django.utils.safestring import mark_safe
from django.utils.html import format_html
from django.utils import six
from django.utils import timezone
register = Library()
@@ -473,7 +474,7 @@ class WithNode(Node):
def render(self, context):
values = dict([(key, val.resolve(context)) for key, val in
self.extra_context.iteritems()])
six.iteritems(self.extra_context)])
context.update(values)
output = self.nodelist.render(context)
context.pop()
@@ -1188,7 +1189,7 @@ def templatetag(parser, token):
if tag not in TemplateTagNode.mapping:
raise TemplateSyntaxError("Invalid templatetag argument: '%s'."
" Must be one of: %s" %
(tag, TemplateTagNode.mapping.keys()))
(tag, list(six.iterkeys(TemplateTagNode.mapping))))
return TemplateTagNode(tag)
@register.tag

View File

@@ -3,6 +3,7 @@ from django.template.base import TemplateSyntaxError, Library, Node, TextNode,\
token_kwargs, Variable
from django.template.loader import get_template
from django.utils.safestring import mark_safe
from django.utils import six
register = Library()
@@ -17,7 +18,7 @@ class BlockContext(object):
self.blocks = {}
def add_blocks(self, blocks):
for name, block in blocks.iteritems():
for name, block in six.iteritems(blocks):
if name in self.blocks:
self.blocks[name].insert(0, block)
else:
@@ -130,7 +131,7 @@ class BaseIncludeNode(Node):
def render_template(self, template, context):
values = dict([(name, var.resolve(context)) for name, var
in self.extra_context.iteritems()])
in six.iteritems(self.extra_context)])
if self.isolated_context:
return template.render(context.new(values))
context.update(values)