Closed mauritsvanrees closed 3 years ago
Maurits van Rees wrote at 2020-8-21 13:49 -0700:
In Zope/templates/chameleon the repeat syntax has changed slightly. Apparently previously you had to call
repeat['widget'].index()
to get the index number, but now you directly get the integer without needing to call it. ... The base template inz3c.form
has the same problem, as do several other templates:$ ack repeat | ack index browser/multi_hidden.pt:6: define="key_widget python:view.key_widgets[repeat['widget'].index()];"> browser/multi_display.pt:25: tal:define="key_widget python:view.key_widgets[repeat['widget'].index()];" browser/multi_input.pt:12: tal:define="key_widget python:view.key_widgets[repeat['widget'].index()];">
This is in
z3c.form
3.7.0. I have no time right now to fix it, only to create an issue.
This is related to "https://github.com/zopefoundation/Zope/issues/875".
In short: zope.tales
(for which z3c.form
has been developed)
defines a so called "Iterator" with methods; for Zope
and
even more chameleon
some of those methods are redefined as
(integer) properties -- introducing an incompatibilty
between Zope
/chameleon
on one side and zope.tales
on the other.
To avoid problems created by those incompatibilities, it is best to access repeat variable metadata (managed by the above "Iterator"s) via path expressions which automatically call methods and thereby hide the method/property difference.
For the cases above, repeat['widget'].index()
could be replaced by path('repeat/widget/index
).
Thanks for your reaction.
That code is how I solve it too.
In Zope/templates/chameleon the repeat syntax has changed slightly. Apparently previously you had to call
repeat['widget'].index()
to get the index number, but now you directly get the integer without needing to call it. See https://github.com/plone/plone.app.z3cform/issues/116 for such a failure inplone.app.z3cform
in a template that overrides a base template inz3c.form
. And see https://github.com/plone/plone.app.z3cform/pull/117 for the fix.The base template in
z3c.form
has the same problem, as do several other templates:This is in
z3c.form
3.7.0. I have no time right now to fix it, only to create an issue.