Пример #1
0
 def __init__(self, keyword, attributes, **kwargs):
     super(CallTag, self).__init__(keyword, attributes, ('args'),
                                   ('expr', ), ('expr', ), **kwargs)
     self.expression = attributes['expr']
     self.code = ast.PythonCode(self.expression, **self.exception_kwargs)
     self.body_decl = ast.FunctionArgs(attributes.get('args', ''),
                                       **self.exception_kwargs)
Пример #2
0
    def __init__(self, keyword, attributes, **kwargs):
        expressions = \
            ['cached', 'args', 'expression_filter', 'enable_loop'] + \
            [c for c in attributes if c.startswith('cache_')]

        super(PageTag, self).__init__(keyword, attributes, expressions, (), (),
                                      **kwargs)
        self.body_decl = ast.FunctionArgs(attributes.get('args', ''),
                                          **self.exception_kwargs)
        self.filter_args = ast.ArgumentList(
            attributes.get('expression_filter', ''), **self.exception_kwargs)
Пример #3
0
    def __init__(self, namespace, defname, attributes, **kwargs):
        super(CallNamespaceTag,
              self).__init__(namespace + ":" + defname, attributes,
                             tuple(attributes.keys()) + ('args', ), (), (),
                             **kwargs)

        self.expression = "%s.%s(%s)" % (namespace, defname, ",".join([
            "%s=%s" % (k, v)
            for k, v in list(self.parsed_attributes.items()) if k != 'args'
        ]))
        self.code = ast.PythonCode(self.expression, **self.exception_kwargs)
        self.body_decl = ast.FunctionArgs(attributes.get('args', ''),
                                          **self.exception_kwargs)
Пример #4
0
    def __init__(self, keyword, attributes, **kwargs):
        expressions = ['buffered', 'cached', 'args'
                       ] + [c for c in attributes if c.startswith('cache_')]

        super(BlockTag,
              self).__init__(keyword, attributes, expressions,
                             ('name', 'filter', 'decorator'), (), **kwargs)
        name = attributes.get('name')
        if name and not re.match(r'^[\w_]+$', name):
            raise errors.CompileException(
                "%block may not specify an argument signature",
                **self.exception_kwargs)
        if not name and attributes.get('args', None):
            raise errors.CompileException(
                "Only named %blocks may specify args", **self.exception_kwargs)
        self.body_decl = ast.FunctionArgs(attributes.get('args', ''),
                                          **self.exception_kwargs)

        self.name = name
        self.decorator = attributes.get('decorator', '')
        self.filter_args = ast.ArgumentList(attributes.get('filter', ''),
                                            **self.exception_kwargs)