tal:define broken for variable self-reference

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

Bug Description

Using cmf.pt in a Plone 4 buildout, when a template does 'define="body_macro context/my_macros/macros/body;"' and then 'use-macro="context/base_edit/macros/master"', the tal:define in base_edit, "body_macro edit_macros/body | body_macro | base_macros/body;", gets the "base_macros/body" instead of the "body_macro" variable. If however, I add "XXX body_macro|nothing;", *right before* the body_macro tal:define in base_edit, then XXX *does* get the right macro.

When I manually change the define in base_edit to "body_macro edit_macros/body | XXX_body_macro | base_macros/body;" and then change the tal:define in my template to "XXX_body_macro", then the tal:define in base_edit gets the right macro for "body_macro".

So it seems that Chameleon doesn't handle self-reference in tal:define assignments correctly.

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

I narrowed this down further. Variable self-reference actually only breaks when the self-reference is made in the second "else" ("|") clause in the expression. Attached is a patch adding test coverage that exposes this bug.

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

It seems this is a problem with variables being carried over as part of dynamic scoping rules. This needs to be condensed into a simple (failing) test for us to continue solving it.

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

Just in case you missed it, did you see the patch with test coverage exposing the bug I attached? Is it not "simple" enough? If not, how so?

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

Looks like Malthe already committed the failing test, this is for my records.

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.