Skip to content
Myr

hopefully fixed `Template`

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent 4f11d74 · Browse files · 1 file+5 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+5 added−6 removed

  • other:+5 added−6 removed

1 file+5 added−6 removed

modified:jinja2/environment.py+5 added-6 removed
146 unmodified lines
147148class Template(object):149 """Represents a template."""150151 def __init__(self, environment, code):152 namespace = {153 'environment': environment154 }151 def __init__(self, environment, code, globals):152 namespace = {'environment': environment}153 exec code in namespace154 self.environment = environment155 self.name = namespace['filename']156 self.root_render_func = namespace['root']
7 unmodified lines
164 return TemplateStream(self.generate(*args, **kwargs))165166 def generate(self, *args, **kwargs):167 # assemble the context168 local_context = dict(*args, **kwargs)169 context = self.globals.copy()171 context.update(*args, **kwargs)170 context.update(local_context)171172 # if the environment is using the optimizer locals may never173 # override globals as optimizations might have happened174 # depending on values of certain globals. This assertion goes175 # away if the python interpreter is started with -O176 if __debug__ and self.environment.optimized:178 overrides = set(context) & set(self.globals)177 overrides = set(local_context) & set(self.globals)178 if overrides:179 plural = len(overrides) != 1 and 's' or ''180 raise AssertionError('the per template variable%s %s '181 'override%s global variable%s. '
7 unmodified lines