Closed thet closed 1 year ago
This is a duplicate of "https://github.com/zopefoundation/Zope/issues/1077".
Note that zope.tales
has no dependence on chameleon
. In addition, the expression types do not strictly belong to zope.tales
itself. From my point of view, this implies the a chameleon
specific extension should be implemented at an integration point of zope.tales
and chameleon
and not in zope.tales
itself (which would make it dependent on chameleon
).
Might z3c.ptcompat be that integration package @d-maurer suggested?
@icemac tnx for the pointer. I wonder if we could just use the Chameleon TALES engine and extend that for path/traversal queries. Maybe something to look into at the Alpine City Sprint next week. I added it to the planning document - maybe I have time to look into that.
Michael Howitz wrote at 2023-2-2 23:12 -0800:
Might
z3c.ptcompat
be that integration package @d-maurer suggested?
As far as I know, Zope
does not use z3c.ptcompat
.
Johannes Raggam wrote at 2023-2-3 00:03 -0800:
@icemac tnx for the pointer. I? wonder if we could just use the Chameleon TALES engine and extend that for path/traversal queries.
Maybe something to look into at the Alpine City Sprint next week. I added it to the planning document - maybe I have time to look into that.
I advocated in the past to use zope.tales
consistently in Zope
because tales expressions are not only used by the template engine
but also for other components (e.g. CMFCore
actions, DCWorkflow
).
chameleon.tales
is not adequate for those use due to its tight
integration with the template engine.
In addition: Zope
's page templates have the method
_pt_getEngine
which specifies which template engine to use.
Overriding this method allows an application already to
specify which tales engine to use.
A new chameleon.tales
integration into Zope
should
(unlike the previous one) honor this method
(some of my extensions depend on it).
FEATURE REQUEST
What I did:
I tried to use a TALES expression like:
What I expect to happen:
The Chameleon documentation lists the syntax above as correct: https://chameleon.readthedocs.io/en/latest/reference.html#id7 https://chameleon.readthedocs.io/en/latest/reference.html#language-extensions
I expected the text to be inserted.
What actually happened:
It failed with:
Some pointers for myself when I revisit this problem:
The PageTemplate engine's
cook
method the TALES engine variant is choosen and in our casezope.tales
used: https://github.com/zopefoundation/Zope/blob/ba37ef2e137029cc1b954b3a21bcd7e1f0bc6bd9/src/Products/PageTemplates/engine.py#L388That cook method is called by
Products.PageTemplates.PageTemplate
super class: https://github.com/zopefoundation/zope.pagetemplate/blob/14ba59c98e12517b9f8abcdb24bc882bb435ed7c/src/zope/pagetemplate/pagetemplate.py#L239In the PageTemplate implementation,
pt_getEngine
returns usesgetEngine
fromfrom Products.PageTemplates.Expressions
: https://github.com/zopefoundation/Zope/blob/ba37ef2e137029cc1b954b3a21bcd7e1f0bc6bd9/src/Products/PageTemplates/PageTemplate.py#L32That returns a
ZopeBaseEngine
instance: https://github.com/zopefoundation/Zope/blob/ba37ef2e137029cc1b954b3a21bcd7e1f0bc6bd9/src/Products/PageTemplates/Expressions.py#L474Chameleon defines a
StructureExpr
, but that is only in the Chameleon TALES engine and not the zope.tales one: https://github.com/malthe/chameleon/blob/1faf6b15b724d64c3e4915f722c31fe063e5e666/src/chameleon/tales.py#L306What version of Python and Zope/Addons I am using:
Python vesion: Python 3.10 OS: Debian Testing
Relevant package versions: