From: Benjamin Wiegand Date: Mon, 28 Apr 2008 16:07:52 +0000 (+0200) Subject: fixed some NameErrors X-Git-Tag: 2.0rc1~123^2~1 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a3152745414dacd9c2b8bafcfdffb670ebe6c5ff;p=jinja2.git fixed some NameErrors --HG-- branch : trunk --- diff --git a/jinja2/exceptions.py b/jinja2/exceptions.py index 0bbe33e..b0853c4 100644 --- a/jinja2/exceptions.py +++ b/jinja2/exceptions.py @@ -45,3 +45,9 @@ class TemplateAssertionError(TemplateSyntaxError): class TemplateRuntimeError(TemplateError): """A runtime error.""" + + +class FilterArgumentError(Exception): + """This error is raised if a filter was called with inappropriate + arguments + """ diff --git a/jinja2/ext.py b/jinja2/ext.py index 5ae317d..1158505 100644 --- a/jinja2/ext.py +++ b/jinja2/ext.py @@ -15,7 +15,7 @@ from jinja2 import nodes from jinja2.environment import get_spontaneous_environment from jinja2.runtime import Undefined, concat from jinja2.parser import statement_end_tokens -from jinja2.exceptions import TemplateAssertionError +from jinja2.exceptions import TemplateAssertionError, TemplateSyntaxError from jinja2.utils import import_string, Markup diff --git a/jinja2/filters.py b/jinja2/filters.py index 4c9766c..0b55760 100644 --- a/jinja2/filters.py +++ b/jinja2/filters.py @@ -19,6 +19,7 @@ from urllib import urlencode, quote from itertools import imap, groupby from jinja2.utils import Markup, escape, pformat, urlize, soft_unicode from jinja2.runtime import Undefined +from jinja2.exceptions import FilterArgumentError _striptags_re = re.compile(r'(|<[^>]*>)') diff --git a/jinja2/nodes.py b/jinja2/nodes.py index f87bbb8..c1231ea 100644 --- a/jinja2/nodes.py +++ b/jinja2/nodes.py @@ -504,7 +504,8 @@ class Subscript(Expr): if self.ctx != 'load': raise Impossible() try: - return environmen.subscribe(self.node.as_const(), self.arg.as_const()) + return self.environment.subscribe(self.node.as_const(), + self.arg.as_const()) except: raise Impossible() diff --git a/jinja2/parser.py b/jinja2/parser.py index 8bc1307..f225ab3 100644 --- a/jinja2/parser.py +++ b/jinja2/parser.py @@ -535,7 +535,7 @@ class Parser(object): if len(args) == 1: arg = args[0] else: - arg = nodes.Tuple(args, lineno, self.filename) + arg = nodes.Tuple(args, self.lineno, self.filename) else: raise TemplateSyntaxError('expected subscript expression', self.lineno, self.filename) diff --git a/jinja2/utils.py b/jinja2/utils.py index 639cda6..0704bb4 100644 --- a/jinja2/utils.py +++ b/jinja2/utils.py @@ -412,7 +412,7 @@ try: from functools import partial except ImportError: class partial(object): - def __init__(self, _func, *args, **kwargs): + def __init__(self, func, *args, **kwargs): self._func = func self._args = args self._kwargs = kwargs