When doing metal:fill-slot, any tal:repeat in the metal:define-slot element should be replaced/ignored

Bug #665748 reported by Ross Patterson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Chamelon Core
Fix Committed
Undecided
Unassigned

Bug Description

Under the reference implementation, when doing metal:fill-slot, any tal:repeat in the metal:define-slot element should be replaced/ignored. Under Chameleon, this is not the case, the tal:repeat is applied to the element that *fills* the slot.

Revision history for this message
Ross Patterson (rossp) wrote :

I've modified some existing coverage to expose this bug.

Revision history for this message
Ross Patterson (rossp) wrote :

For further reference, here's a changeset I had to make to workaround this issue:

https://dev.plone.org/collective/changeset/146736/

Revision history for this message
Malthe Borch (mborch) wrote :

This might be a fix (simple reordering of the repeat- and fill-slot clauses).

Changed in chameleon.core:
status: New → Confirmed
Revision history for this message
Ross Patterson (rossp) wrote :

That patch causes a failure in z3c.pt:

Failure in test /home/xen/src/work/ovt.buildout/src/Chameleon/src/chameleon/zpt/language.txt
Traceback (most recent call last):
  File "/usr/lib/python2.6/unittest.py", line 279, in run
    testMethod()
  File "/usr/lib/python2.6/doctest.py", line 2163, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for language.txt
  File "/home/xen/src/work/ovt.buildout/src/Chameleon/src/chameleon/zpt/language.txt", line 0

----------------------------------------------------------------------
File "/home/xen/src/work/ovt.buildout/src/Chameleon/src/chameleon/zpt/language.txt", line 281, in language.txt
Failed example:
    print render("""\
    <div xmlns="http://www.w3.org/1999/xhtml"
         xmlns:tal="http://xml.zope.org/namespaces/tal">
      <tal:example replace="'Hello World!'" />
      <tal:example tal:replace="'Hello World!'" />
      <tal:div content="'Hello World!'" />
      <tal:multiple repeat="i range(3)" replace="i" />
      <tal:div condition="True">True</tal:div>
    </div>""")
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib/python2.6/doctest.py", line 1253, in __run
        compileflags, 1) in test.globs
      File "<doctest language.txt[18]>", line 9, in <module>
        </div>""")
      File "<doctest language.txt[2]>", line 4, in render
        return func(**kwargs)
      File "/home/xen/src/work/ovt.buildout/src/Chameleon/src/chameleon/core/testing.py", line 77, in render
        result = func(econtext, rcontext)
      File "/tmp/tmpwyRe8g/tmpJoA4w_.py", line 120, in render
      File "/home/xen/src/work/ovt.buildout/src/Chameleon/src/chameleon/core/utils.py", line 332, in __getitem__
        raise NameError(key)
    NameError: i

Which makes sense. the question is, does the reference implementation support tal:replace/content/define/attributes="i" in the same element as tal:repeat="i ..."?

Revision history for this message
Ross Patterson (rossp) wrote :

Malthe, any thoughts on my previous comment?

Revision history for this message
Ross Patterson (rossp) wrote :

I confirmed that the reference implementation does support referencing a repeat variable in the same element as the repeat statement. So that means Malthe's proposed fix introduces another bug. This will require more help from Malthe to get the scoping right.

Revision history for this message
Ross Patterson (rossp) wrote :

Actually, all that was required was to move *both* the "# repeat" and "# assign" blocks down further. Fixes the failing test and doesn't cause any other failures.

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

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.