PageTemplate macro expansion check cannot handle recursive macros
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
zope.pagetemplate |
Invalid
|
Undecided
|
Unassigned |
Bug Description
Consider this page template, based on a real example (which is z3c.formui's div-form.pt):
<ul metal:define-
<li tal:content=
<li tal:repeat="context context/children">
<ul metal:use-
</li>
</ul>
Note that the macro is recursive, but it is not infinitely recursive, since it redefines 'context' and the metal:use-macro call is conditioned on a TALES expression "context/children" returning a non-empty list.
If you attempt to call pt_render(
This is painful because PageTemplateTra
I think the best fix would be to make TALInterpreter (from zope.tal) perform a recursion check in do_useMacro: if the same macro already appears in the macro stack, *and* self.tal is False, then the recursive macro expansion should silently stop.
In the shorter term I'm considering a workaround that disables macro expansion checks just for PageTemplateTra cebackSupplemen t.