Built in path/string/exists/nocall methods not available in python TALES expression #126

tsimkins opened this Issue Sep 7, 2012 · 2 comments


None yet

2 participants

tsimkins commented Sep 7, 2012

We're on Chameleon 2.9.2, Plone 4.1.6

Per the ZPT docs:


You could use the path, string, exists, and nocall methods as part of a python TALES expression.

For example,

<div tal:content="python: string(context/some_url_var)"></div>

where "some_url_var" could be something like, "${portal_url}/foo/bar". In upgrading to Plone 4.1 with Chameleon, I noticed that these methods are not available.

I worked around the issue, since I only used that functionality one place, but it would be nice to have it available.

Sample traceback is:

2012-09-07 12:53:56 ERROR portlets Error while rendering <plone.app.portlets.manager.ColumnPortletManagerRenderer object at 0xf77652c>
Traceback (most recent call last):
  File "/usr/local/plone/buildout-cache/eggs/Products.PloneFormGen-1.7.2-py2.6.egg/Products/PloneFormGen/patches.py", line 20, in safe_render
    return portlet_renderer.render()
  File "/usr/local/plone/buildout-cache/eggs/Zope2-2.13.15-py2.6.egg/Products/Five/browser/pagetemplatefile.py", line 125, in __call__
    return self.im_func(im_self, *args, **kw)
  File "/usr/local/plone/buildout-cache/eggs/Zope2-2.13.15-py2.6.egg/Products/Five/browser/pagetemplatefile.py", line 59, in __call__
    sourceAnnotations=getattr(debug_flags, 'sourceAnnotations', 0),
  File "/usr/local/plone/buildout-cache/eggs/zope.pagetemplate-3.6.2-py2.6.egg/zope/pagetemplate/pagetemplate.py", line 132, in pt_render
    strictinsert=0, sourceAnnotations=sourceAnnotations
  File "/usr/local/plone/buildout-cache/eggs/five.pt-2.2.1-py2.6.egg/five/pt/engine.py", line 93, in __call__
    return self.template.render(**kwargs)
  File "/usr/local/plone/buildout-cache/eggs/z3c.pt-2.2.3-py2.6.egg/z3c/pt/pagetemplate.py", line 149, in render
    return base_renderer(**context)
  File "/usr/local/plone/buildout-cache/eggs/Chameleon-2.9.2-py2.6.egg/chameleon/zpt/template.py", line 259, in render
    return super(PageTemplate, self).render(**vars)
  File "/usr/local/plone/buildout-cache/eggs/Chameleon-2.9.2-py2.6.egg/chameleon/template.py", line 190, in render
    raise_with_traceback(exc, tb)
  File "/usr/local/plone/buildout-cache/eggs/Chameleon-2.9.2-py2.6.egg/chameleon/template.py", line 172, in render
    self._render(stream, econtext, rcontext)
  File "962c6c1f098dc71084de66898e708ba356b5a0cb.py", line 119, in render
  File "/usr/local/plone/buildout-cache/eggs/Chameleon-2.9.2-py2.6.egg/chameleon/utils.py", line 404, in __getitem__
    raise NameError(key)
NameError: string

 - Expression: "python: string('${portal_url}')"
 - Filename:   ... [_____REDACTED_____]/browser/templates/navigation.pt
 - Location:   (10:16)
 - Source:     foo python: string('${portal_url}');
 - Arguments:  repeat: {...} (0)
               template: <ViewPageTemplateFile - at 0xcb8140c>
               views: <ViewMapper - at 0xf40610c>
               modules: <instance - at 0x9a772ec>
               subsite_url: [_____REDACTED_____]
               args: <tuple - at 0xb769c02cL>
               here: <ImplicitAcquisitionWrapper academics at 0xf9d2c5c>
               user: <ImplicitAcquisitionWrapper - at 0xf6c2734>
               view: <PortletRenderer from [_____REDACTED_____]/browser/templates/navigation.pt - at 0xfba5eec>
               nothing: <NoneType - at 0x8172db8>
               container: <ImplicitAcquisitionWrapper academics at 0xf9d2c5c>
               include_top: True
               request: <instance - at 0xf564a4c>
               wrapped_repeat: <SafeMapping - at 0xf6bc1bc>
               portal_url: [_____REDACTED_____]
               traverse_subpath: <list - at 0xf75cb2c>
               default: <object - at 0xb76bb7d0L>
               loop: {...} (0)
               context: <ImplicitAcquisitionWrapper academics at 0xf9d2c5c>
               subsite_title: Future Students
               translate: <function translate at 0xf8ff7d4>
               root: <ImplicitAcquisitionWrapper academics at 0xf6bc734>
               options: {...} (0)
               target_language: en

malthe commented Oct 8, 2012

At least path and exists should be implemented. I have never heard of string and nocall as functions, but if you say they're usually available, then it's a valid bug :-).

@malthe malthe added wontfix and removed wontfix labels Dec 6, 2016
@malthe malthe referenced this issue in zopefoundation/z3c.pt Dec 6, 2016

Add "string" and "nocall" functions #2

malthe commented Dec 6, 2016

Reopened here: zopefoundation/z3c.pt#2.

@malthe malthe closed this Dec 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment