ZPT: "python: CONTEXTS" gives NameError

Bug #142273 reported by Willem on 2002-10-14
4
Affects Status Importance Assigned to Milestone
zope.tales
Won't Fix
Wishlist
Unassigned

Bug Description

In page templates, the built-in variable 'CONTEXTS' is not accessible inside python expressions:

  <div tal:replace="python: CONTEXTS" />
  -> NameError on global name 'CONTEXTS'

while it works fine outside python expressions:

  <div tal:replace="CONTEXTS" />

and the other built-in variables work fine, too:

  <div tal:replace="python: attrs" />

The TALES documentation mentioning CONTEXTS is at:
 <http://www.zope.org/Wikis/DevSite/Projects/ZPT/TALES%20Specification%201.3>

Evan Simpson (evan-4-am) wrote :

Status: Pending => Resolved

Fixed in HEAD and 2.7 branch.

LeoRochael (leorochael) wrote :

This bug is once again affects Zope 2.12. It used to work on Zope 2.8 but stopped working at some point and now I have a ton of code affected by it while trying to migrate.

It can be worked around with 'path("CONTEXT")', but it's a pain to convert a bunch of TTW code in formulator instances, and the original version should work. Steps to reproduce are as in the original submission.

It works for path expressions because 'CONTEXTS' is hardcoded there, instead of being added as a variable to the evaluation context.

Changed in zope2:
importance: Low → Medium
status: Fix Released → Confirmed
Tres Seaver (tseaver) wrote :

- Zope2 no longer bundles a separate TALES implementation. Any fix will
  need to land in zope.tales.

- The docs mention the user of the CONTEXTS special name only when document
  path expressions. I don't even know why you expect to use that name
  elsewhere, but the fact that it happened to work at some point was
  basically an implementation detail. I would plan on fixing your code,
  or else do the work to submit a patch with tests.

affects: zope2 → zope.tales
Changed in zope.tales:
importance: Medium → Wishlist
status: Confirmed → Triaged
Tres Seaver (tseaver) on 2012-05-23
Changed in zope.tales:
status: Triaged → Won't Fix
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers