removed custom nodes again
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 0553093 · Browse files · 3 files·+7 added−32 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+7 added−32 removed
- other:+7 added−32 removed
Provenance
- Commit
7324eb8- Tree
7a0fe84- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent
0553093
3 files changed+7 added−32 removed
modified:jinja2/compiler.py-6 removed
278 unmodified lines279 280 # the current indentation281 self._indentation = 0282 283- def get_visitor(self, node):284- """Custom nodes have their own compilation method."""285- if isinstance(node, nodes.CustomStmt):286- return node.compile287- return NodeVisitor.get_visitor(self, node)288-283 def temporary_identifier(self):284 """Get a new unique identifier."""285 self._last_identifier += 1286 return 't%d' % self._last_identifier772 unmodified linesmodified:jinja2/i18n.py+3 added-1 removed
73 unmodified lines74 options.get('variable_end_string', '}}'),75 options.get('comment_start_string', '{#'),76 options.get('comment_end_string', '#}'),77 options.get('line_statement_prefix') or None,78- options.get('trim_blocks', '').lower() in ('1', 'on', 'yes', 'true')78+ options.get('trim_blocks', '').lower() in ('1', 'on', 'yes', 'true'),79+ extensions=[x.strip() for x in options.get('extensions', '')80+ .split(',')] + [TransExtension]81 )82 node = environment.parse(fileobj.read().decode(encoding))83 for lineno, func, message in extract_from_ast(node, keywords):84 yield lineno, func, message, []153 unmodified linesmodified:jinja2/nodes.py+4 added-25 removed
56 unmodified lines57 58 def __new__(cls, name, bases, d):59 for attr in 'fields', 'attributes':60 storage = []61- for base in bases:62- storage.extend(getattr(base, attr, ()))61+ storage.extend(getattr(bases[0], attr, ()))62 storage.extend(d.get(attr, ()))64- assert len(storage) == len(set(storage))63+ assert len(bases) == 1, 'multiple inheritance not allowed'64+ assert len(storage) == len(set(storage)), 'layout conflict'65 d[attr] = tuple(storage)66- rv = type.__new__(cls, name, bases, d)66+ return type.__new__(cls, name, bases, d)67 68- # unless the node is a subclass of `CustomNode` it may not69- # be defined in any other module than the jinja2.nodes module.70- # the reason for this is that the we don't want users to take71- # advantage of the fact that the parser is using the node name72- # only as callback name for non custom nodes. This could lead73- # to broken code in the future and is disallowed because of this.74- if rv.__module__ != 'jinja2.nodes' and not \75- isinstance(rv, CustomStmt):76- raise TypeError('non builtin node %r is not a subclass of '77- 'CustomStmt.' % node.__class__.__name__)78- return rv68 80-69 class Node(object):70 """Baseclass for all Jinja nodes."""71 __metaclass__ = NodeType72 fields = ()119 unmodified lines192 class Helper(Node):193 """Nodes that exist in a specific context only."""194 195 208-class CustomStmt(Stmt):209- """Custom statements must extend this node."""210-211- def compile(self, compiler):212- """The compiler calls this method to get the python sourcecode213- for the statement.214- """215-216-196 class Template(Node):197 """Node that represents a template."""198 fields = ('body',)199 388 unmodified lines