[Checkins] SVN: z3c.pt/trunk/ Macro-objects are no longer callable; instead, a render method is provided. This makes it possible to use path-expressions to get to macros.
Malthe Borch
mborch at gmail.com
Tue Sep 9 17:42:18 EDT 2008
Log message for revision 91008:
Macro-objects are no longer callable; instead, a render method is provided. This makes it possible to use path-expressions to get to macros.
Changed:
U z3c.pt/trunk/CHANGES.txt
U z3c.pt/trunk/src/z3c/pt/macro.py
U z3c.pt/trunk/src/z3c/pt/translation.py
-=-
Modified: z3c.pt/trunk/CHANGES.txt
===================================================================
--- z3c.pt/trunk/CHANGES.txt 2008-09-09 21:39:47 UTC (rev 91007)
+++ z3c.pt/trunk/CHANGES.txt 2008-09-09 21:42:18 UTC (rev 91008)
@@ -169,6 +169,11 @@
Bugfixes
+- ``Macros`` class should not return callable functions, but rather a
+ ``Macro`` object, which has a ``render``-method. This makes it
+ possible to use a path-expression to get to a macro without calling
+ it. [malthe]
+
- Fixed bug where a repeat-clause would reset the repeat variable
before evaluating the expression. [malthe]
Modified: z3c.pt/trunk/src/z3c/pt/macro.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/macro.py 2008-09-09 21:39:47 UTC (rev 91007)
+++ z3c.pt/trunk/src/z3c/pt/macro.py 2008-09-09 21:42:18 UTC (rev 91008)
@@ -1,3 +1,7 @@
+class Macro(object):
+ def __init__(self, render):
+ self.render = render
+
class Macros(object):
def __init__(self, render):
self.render = render
@@ -5,4 +9,4 @@
def __getitem__(self, name):
def render(**kwargs):
return self.render(macro=name, **kwargs)
- return render
+ return Macro(render)
Modified: z3c.pt/trunk/src/z3c/pt/translation.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/translation.py 2008-09-09 21:39:47 UTC (rev 91007)
+++ z3c.pt/trunk/src/z3c/pt/translation.py 2008-09-09 21:42:18 UTC (rev 91008)
@@ -277,9 +277,9 @@
tuple("%s=%s" % (arg, arg) for arg in \
itertools.chain(*self.stream.scope))+
tuple("%s=%s" % kwarg for kwarg in kwargs))
-
+
_.append(clauses.Write(
- types.value("%s(%s)" % (self.symbols.metal, arguments))))
+ types.value("%s.render(%s)" % (self.symbols.metal, arguments))))
# translate body
elif self.translate is not None:
More information about the Checkins
mailing list