aboutsummaryrefslogtreecommitdiffstats
path: root/lib/mako/ast.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2006-12-16 20:32:34 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2006-12-16 20:32:34 +0000
commit4d3dbb32855df3458f2e50119f2ae5ddce6c5294 (patch)
tree61de853cb220497cdce6d85a299b10fbdd2d483b /lib/mako/ast.py
parentdaea93472a83a20d66f074b801ff96188630d11b (diff)
downloadexternal_python_mako-4d3dbb32855df3458f2e50119f2ae5ddce6c5294.tar.gz
external_python_mako-4d3dbb32855df3458f2e50119f2ae5ddce6c5294.tar.bz2
external_python_mako-4d3dbb32855df3458f2e50119f2ae5ddce6c5294.zip
took out the whole "auto-propigation of **kwargs" thing,
implemented "args" for <%page> tag. still has a default "**_extra_pageargs" catchall for now...
Diffstat (limited to 'lib/mako/ast.py')
-rw-r--r--lib/mako/ast.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/mako/ast.py b/lib/mako/ast.py
index c2e0394..e44e5a8 100644
--- a/lib/mako/ast.py
+++ b/lib/mako/ast.py
@@ -145,7 +145,7 @@ class walker(visitor.ASTVisitor):
class FunctionDecl(object):
"""function declaration"""
- def __init__(self, code, lineno, pos, filename):
+ def __init__(self, code, lineno, pos, filename, allow_kwargs=True):
self.code = code
expr = parse(code, "exec", lineno, pos, filename)
class ParseFunc(object):
@@ -160,6 +160,9 @@ class FunctionDecl(object):
visitor.walk(expr, f)
if not hasattr(self, 'funcname'):
raise exceptions.CompileException("Code '%s' is not a function declaration" % code, lineno, pos, filename)
+ if not allow_kwargs and self.kwargs:
+ raise exceptions.CompileException("'**%s' keyword argument not allowed here" % self.argnames[-1], lineno, pos, filename)
+
def get_argument_expressions(self, include_defaults=True):
"""return the argument declarations of this FunctionDecl as a printable list."""
namedecls = []
@@ -186,8 +189,8 @@ class FunctionDecl(object):
class FunctionArgs(FunctionDecl):
"""the argument portion of a function declaration"""
- def __init__(self, code, lineno, pos, filename):
- super(FunctionArgs, self).__init__("def ANON(%s):pass" % code, lineno, pos, filename)
+ def __init__(self, code, lineno, pos, filename, **kwargs):
+ super(FunctionArgs, self).__init__("def ANON(%s):pass" % code, lineno, pos, filename, **kwargs)
class ExpressionGenerator(object):