zopefoundation / zope.tales

Template Attribute Language - Expression Syntax -- see https://zope.readthedocs.io/en/latest/zope2book/AppendixC.html
Other
3 stars 7 forks source link

Chameleon TALES‌ extension `structure` does not work #30

Closed thet closed 1 year ago

thet commented 1 year ago

FEATURE REQUEST

What I did:

I tried to use a TALES expression like:

<div tal:define="test_string string:ok">
${structure: test_string}
</div>

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:

2023-02-01 15:29:31,831 ERROR   [root:38][waitress-1] PageTemplateFile: Error in template /[...]/browser/templates/test_template.pt: Compilation failed
builtins.LookupError: Unknown expression type: 'structure'.
[20] > /home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/Products.PDBDebugMode-2.0-py3.10.egg/Products/PDBDebugMode/pdblogging.py(59)error()
-> return result
(Pdb++) 
2023-02-01 15:29:31,858 INFO    [Products.CMFPlone.browser.icons:102][waitress-1] Icon resolver lookup of 'http:' failed, fallback to Plone icon.
2023-02-01 15:29:31,915 ERROR   [Zope.SiteErrorLog:17][waitress-1] BdbQuit: http://localhost:8080/Plone/test_view
Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 172, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 381, in publish_module
  Module ZPublisher.WSGIPublisher, line 276, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module Products.PDBDebugMode.wsgi_runcall, line 60, in pdb_runcall
  Module recensio.plone.browser.review, line 600, in __call__
  Module zope.browserpage.simpleviewclass, line 41, in __call__
  Module Products.Five.browser.pagetemplatefile, line 126, in __call__
  Module Products.Five.browser.pagetemplatefile, line 58, in __call__
  Module zope.pagetemplate.pagetemplate, line 122, in pt_render
  Module Products.CMFPlone.patches.templatecookcheck, line 27, in _cook_check
   - __traceback_info__: /[...]/browser/templates/test_template.pt
  Module logging, line 2105, in error
  Module Products.PDBDebugMode.pdblogging, line 59, in error
  Module Products.PDBDebugMode.pdblogging, line 59, in error
  Module bdb, line 90, in trace_dispatch
  Module bdb, line 115, in dispatch_line
bdb.BdbQuit
[15] > /usr/lib/python3.10/bdb.py(115)dispatch_line()
-> if self.quitting: raise BdbQuit
(Pdb++) 

Some pointers for myself when I revisit this problem:

What version of Python and Zope/Addons I am using:

Python vesion: Python 3.10 OS: Debian Testing

$ uname -a
Linux then 6.1.0-1-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.4-1 (2023-01-07) x86_64 GNU/Linux

Relevant package versions:

d-maurer commented 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).

icemac commented 1 year ago

Might z3c.ptcompat be that integration package @d-maurer suggested?

thet commented 1 year ago

@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.

d-maurer commented 1 year ago

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.

d-maurer commented 1 year ago

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).