本文整理汇总了Python中django.template.context.Context.pop方法的典型用法代码示例。如果您正苦于以下问题:Python Context.pop方法的具体用法?Python Context.pop怎么用?Python Context.pop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.template.context.Context
的用法示例。
在下文中一共展示了Context.pop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: healed_context
# 需要导入模块: from django.template.context import Context [as 别名]
# 或者: from django.template.context.Context import pop [as 别名]
def healed_context(context):
"""
.. testcase:: HealedContextTestCase
"""
if not isinstance(context, BaseContext):
context = Context(context)
original_context_length = len(context.dicts)
yield context
ctx_length = len(context.dicts)
while ctx_length > 1 and ctx_length > original_context_length:
logger.debug('Removing excess context dicts (target size {0},'
'working size {1})'.format(original_context_length,
ctx_length))
context.pop()
ctx_length = len(context.dicts)
示例2: CommandError
# 需要导入模块: from django.template.context import Context [as 别名]
# 或者: from django.template.context.Context import pop [as 别名]
jingo.register.env,
compiled_node,
{}
).render(context))
try:
context['compress_forced'] = True
compiled_node = env.compile(jinja2.nodes.Template([node]))
result = Template.from_code(
env,
compiled_node,
{}).render(context)
except Exception, e:
raise CommandError("An error occured during rendering %s: "
"%s" % (template.template_name, e))
offline_manifest[key] = result
context.pop()
results.append(result)
count += 1
write_offline_manifest(offline_manifest)
log.write("done\nCompressed %d block(s) from %d template(s).\n" %
(count, len(compressor_nodes)))
return count, results
def get_nodelist(self, node):
if (isinstance(node, IfNode) and
hasattr(node, 'nodelist_true') and
hasattr(node, 'nodelist_false')):
return node.nodelist_true + node.nodelist_false
return getattr(node, "body", getattr(node, "nodes", []))