From: Armin Ronacher Date: Sat, 3 Mar 2007 12:15:04 +0000 (+0100) Subject: [svn] some small fixes and django compatibility for jinja X-Git-Tag: 2.0rc1~474 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e55ed10f0b70ae7ff841c8579da345f8d9537d8d;p=jinja2.git [svn] some small fixes and django compatibility for jinja --HG-- branch : trunk --- diff --git a/jinja/datastructure.py b/jinja/datastructure.py index 37a3dce..7a69ec5 100644 --- a/jinja/datastructure.py +++ b/jinja/datastructure.py @@ -148,11 +148,11 @@ class Context(object): return Undefined def __setitem__(self, name, value): - self._stack[-1][name] = value + self.current[name] = value def __delitem__(self, name): - if name in self._stack[-1]: - del self._stack[-1][name] + if name in self.current: + del self.current[name] def __repr__(self): tmp = {} diff --git a/jinja/environment.py b/jinja/environment.py index d413be9..701c4d2 100644 --- a/jinja/environment.py +++ b/jinja/environment.py @@ -58,7 +58,7 @@ class Environment(object): # global namespace self.globals = namespace is None and DEFAULT_NAMESPACE.copy() \ - or namespace + or namespace or {} # create lexer self.lexer = Lexer(self) @@ -153,7 +153,8 @@ class Environment(object): args += tuple(dyn_args) elif dyn_kwargs is not None: kwargs.update(dyn_kwargs) - if getattr(f, 'jinja_unsafe_call', False): + if getattr(f, 'jinja_unsafe_call', False) or \ + getattr(f, 'alters_data', False): raise SecurityException('unsafe function %r called' % f.__name__) return f(*args, **kwargs) diff --git a/jinja/parser.py b/jinja/parser.py index d25b9d3..0c4dcb1 100644 --- a/jinja/parser.py +++ b/jinja/parser.py @@ -137,7 +137,7 @@ class Parser(object): except (StopIteration, ValueError): raise TemplateSyntaxError('invalid syntax for set', lineno) ast = self.parse_python(lineno, gen, '(%s)') - return nodes.Set(lineno, name[1], ast.expr) + return nodes.Set(lineno, name[2], ast.expr) def handle_filter_directive(self, lineno, gen): """