provider expression does not support variables

Bug #342832 reported by Michael Howitz on 2009-03-14
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Chamelon Core
Undecided
Unassigned

Bug Description

When rendering the following template:

<li class="current"
     tal:define="subProviderName view/subMenuProviderName">
  <tal:block condition="subProviderName"
                  replace="structure provider:${subProviderName}">sub menu items</tal:block>
</li>

I get this exception:

    Traceback (most recent call last):
      File "/Users/mac/Documents/eggs/zope.testing-3.7.1-py2.5.egg/zope/testing/doctest.py", line 1356, in __run
        compileflags, 1) in test.globs
      ...
      File "/Users/mac/Documents/eggs/zope.publisher-3.5.6-py2.5.egg/zope/publisher/publish.py", line 108, in mapply
        return debug_call(obj, args)
      File "/Users/mac/Documents/eggs/zope.publisher-3.5.6-py2.5.egg/zope/publisher/publish.py", line 114, in debug_call
        return obj(*args)
      File "/Users/mac/Documents/eggs/z3c.pagelet-1.0.2-py2.5.egg/z3c/pagelet/browser.py", line 55, in __call__
        return layout(self)
      File "/Users/mac/Documents/eggs/z3c.pt-1.0b12-py2.5.egg/z3c/pt/pagetemplate.py", line 196, in __call__
        _ob=_ob, **kwargs)
      File "/Users/mac/Documents/eggs/z3c.pt-1.0b12-py2.5.egg/z3c/pt/pagetemplate.py", line 105, in __call__
        return bound_pt(**kwargs)
      File "/Users/mac/Documents/eggs/z3c.pt-1.0b12-py2.5.egg/z3c/pt/pagetemplate.py", line 215, in __call__
        return self.im_func(**kw)
      File "/Users/mac/Documents/eggs/z3c.pt-1.0b12-py2.5.egg/z3c/pt/pagetemplate.py", line 96, in render
        return self.render(**context)
      File "/Users/mac/Documents/eggs/chameleon.core-1.0b23-py2.5.egg/chameleon/core/template.py", line 222, in render
        return super(TemplateFile, self).render(**kwargs)
      File "/Users/mac/Documents/eggs/chameleon.core-1.0b23-py2.5.egg/chameleon/core/template.py", line 112, in render
        return self.render_template(template, **kwargs)
      File "/Users/mac/Documents/eggs/chameleon.core-1.0b23-py2.5.egg/chameleon/core/template.py", line 131, in render_template
        __template__.source, repr(self), kwargs, sys.exc_info())
      File "/Users/mac/Documents/eggs/chameleon.core-1.0b23-py2.5.egg/chameleon/core/template.py", line 128, in render_template
        return __template__.render(**kwargs)
      File "/var/folders/SR/SRmqqK4THC0XA5jzpFcGCU+++TM/-Tmp-/tmpcOSOS_", line 50, in render
        _content = _get_content_provider(context, request, view, 'main-menu')
      File "/Users/mac/Documents/eggs/z3c.pt-1.0b12-py2.5.egg/z3c/pt/expressions.py", line 39, in __call__
        return cp.render()
      File "/Users/mac/Documents/eggs/zope.viewlet-3.5.0-py2.5.egg/zope/viewlet/manager.py", line 169, in render
        return u'\n'.join([viewlet.render() for viewlet in self.viewlets])
      File "/Users/mac/Documents/eggs/z3c.menu.ready2go-0.6.0-py2.5.egg/z3c/menu/ready2go/item.py", line 122, in render
        return self.template()
      File "/Users/mac/Documents/eggs/z3c.template-1.2.0-py2.5.egg/z3c/template/template.py", line 64, in __call__
        return self.im_func(im_self, *args, **kw)
      File "/Users/mac/Documents/eggs/z3c.template-1.2.0-py2.5.egg/z3c/template/template.py", line 86, in __call__
        return template(instance, *args, **keywords)
      File "/Users/mac/Documents/eggs/z3c.pt-1.0b12-py2.5.egg/z3c/pt/pagetemplate.py", line 196, in __call__
        _ob=_ob, **kwargs)
      File "/Users/mac/Documents/eggs/z3c.pt-1.0b12-py2.5.egg/z3c/pt/pagetemplate.py", line 105, in __call__
        return bound_pt(**kwargs)
      File "/Users/mac/Documents/eggs/z3c.pt-1.0b12-py2.5.egg/z3c/pt/pagetemplate.py", line 215, in __call__
        return self.im_func(**kw)
      File "/Users/mac/Documents/eggs/z3c.pt-1.0b12-py2.5.egg/z3c/pt/pagetemplate.py", line 96, in render
        return self.render(**context)
      File "/Users/mac/Documents/eggs/chameleon.core-1.0b23-py2.5.egg/chameleon/core/template.py", line 222, in render
        return super(TemplateFile, self).render(**kwargs)
      File "/Users/mac/Documents/eggs/chameleon.core-1.0b23-py2.5.egg/chameleon/core/template.py", line 111, in render
        template = self.cook_check(parameters=kwargs)
      File "/Users/mac/Documents/eggs/chameleon.core-1.0b23-py2.5.egg/chameleon/core/template.py", line 106, in cook_check
        template = self.cook(parameters=parameters, **kwargs)
      File "/Users/mac/Documents/eggs/chameleon.core-1.0b23-py2.5.egg/chameleon/core/template.py", line 198, in cook
        raise exception
    RuntimeError: Caught exception rendering template.
     - Expression: "main-menu"
     - Instance: <ViewPageTemplateFile /Users/mac/Documents/tmp/icemac.addressbook/src/icemac/addressbook/browser/layout.pt>
     - Arguments: template: <ViewPageTemplateFile - at 0x43915d0>
                   exists: <function evaluate_exists at 0x3211870>
                   modules: {...} (1977)
                   nothing: <NoneType - at 0x1076a0>
                   path: <function evaluate_path at 0x3203bb0>
                   xincludes: <XIncludes - at 0x4391610>
                   request: <BrowserRequest - at 0x47013f0>
                   context: <_Proxy AddressBook at 0x4969a30>
                   view: <SimplePagelet index.html at 0x4969b90>
                   options: {...} (2)
                   target_language: <NoneType - at 0x1076a0>

    SyntaxError: ${subProviderName} is not a valid content provider name. (/Users/mac/Documents/eggs/z3c.menu.ready2go-0.6.0-py2.5.egg/z3c/menu/ready2go/item.pt)

I seems that a variable provider name expression is not yet supported.

Download full text (11.9 KiB)

That's true; but it can quite easily be supported.

On 14/03/2009, Michael Howitz <email address hidden> wrote:
> Public bug reported:
>
> When rendering the following template:
>
> <li class="current"
> tal:define="subProviderName view/subMenuProviderName">
> <tal:block condition="subProviderName"
> replace="structure provider:${subProviderName}">sub menu
> items</tal:block>
> </li>
>
> I get this exception:
>
> Traceback (most recent call last):
> File
> "/Users/mac/Documents/eggs/zope.testing-3.7.1-py2.5.egg/zope/testing/doctest.py",
> line 1356, in __run
> compileflags, 1) in test.globs
> ...
> File
> "/Users/mac/Documents/eggs/zope.publisher-3.5.6-py2.5.egg/zope/publisher/publish.py",
> line 108, in mapply
> return debug_call(obj, args)
> File
> "/Users/mac/Documents/eggs/zope.publisher-3.5.6-py2.5.egg/zope/publisher/publish.py",
> line 114, in debug_call
> return obj(*args)
> File
> "/Users/mac/Documents/eggs/z3c.pagelet-1.0.2-py2.5.egg/z3c/pagelet/browser.py",
> line 55, in __call__
> return layout(self)
> File
> "/Users/mac/Documents/eggs/z3c.pt-1.0b12-py2.5.egg/z3c/pt/pagetemplate.py",
> line 196, in __call__
> _ob=_ob, **kwargs)
> File
> "/Users/mac/Documents/eggs/z3c.pt-1.0b12-py2.5.egg/z3c/pt/pagetemplate.py",
> line 105, in __call__
> return bound_pt(**kwargs)
> File
> "/Users/mac/Documents/eggs/z3c.pt-1.0b12-py2.5.egg/z3c/pt/pagetemplate.py",
> line 215, in __call__
> return self.im_func(**kw)
> File
> "/Users/mac/Documents/eggs/z3c.pt-1.0b12-py2.5.egg/z3c/pt/pagetemplate.py",
> line 96, in render
> return self.render(**context)
> File
> "/Users/mac/Documents/eggs/chameleon.core-1.0b23-py2.5.egg/chameleon/core/template.py",
> line 222, in render
> return super(TemplateFile, self).render(**kwargs)
> File
> "/Users/mac/Documents/eggs/chameleon.core-1.0b23-py2.5.egg/chameleon/core/template.py",
> line 112, in render
> return self.render_template(template, **kwargs)
> File
> "/Users/mac/Documents/eggs/chameleon.core-1.0b23-py2.5.egg/chameleon/core/template.py",
> line 131, in render_template
> __template__.source, repr(self), kwargs, sys.exc_info())
> File
> "/Users/mac/Documents/eggs/chameleon.core-1.0b23-py2.5.egg/chameleon/core/template.py",
> line 128, in render_template
> return __template__.render(**kwargs)
> File "/var/folders/SR/SRmqqK4THC0XA5jzpFcGCU+++TM/-Tmp-/tmpcOSOS_",
> line 50, in render
> _content = _get_content_provider(context, request, view,
> 'main-menu')
> File
> "/Users/mac/Documents/eggs/z3c.pt-1.0b12-py2.5.egg/z3c/pt/expressions.py",
> line 39, in __call__
> return cp.render()
> File
> "/Users/mac/Documents/eggs/zope.viewlet-3.5.0-py2.5.egg/zope/viewlet/manager.py",
> line 169, in render
> return u'\n'.join([viewlet.render() for viewlet in self.viewlets])
> File
> "/Users/mac/Documents/eggs/z3c.menu.ready2go-0.6.0-py2.5.egg/z3c/menu/ready2go/item.py",
> line 122, in render
> return self.template()
> File
> "/Users/mac/Documents/eggs/z3c.template-1.2.0-py2....

Malthe Borch (mborch) wrote :

Oh I see now; this should be a string-like expression, allowing interpolation with ${}.

Changed in chameleon.core:
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers