Strange behavior with TAL and python: expressions
Great and mighty Zope gurus, I have a template which calls a macro. Within the template, I tal:define a variable, 'form'. Within the macro, the 'form' variable (which is an FSForm object) is defined as None unless I access it using python expressions. If I attempt to do anything with attributes of 'form', I get an AttributeError indicating that the NoneType object, form, doesn't have the attribute that I'm looking for. However, I can use 'form' any way I want inside the template that calls the macro. It seems that the macro call somehow lost part of the information associated with the 'form' variable. I worked around the problem by defining form using a python expression instead of a pure TALES expression. I was also able to work around the issue by accessing 'form' within the macro using python expressions instead of TALES. Why would this happen? Is this expected? I'm using Zope 2.7.5 and Formulator 1.9. I'm not sure what other products to list here; this seems like a ZPT-related thing. Please let me know if there is any more information I can provide. Thanks! -- Floyd May Senior Systems Analyst CTLN - CareerTech Learning Network fmay@okcareertech.org
Floyd May wrote:
Great and mighty Zope gurus,
At last, some respect ;-)
I have a template which calls a macro. Within the template, I tal:define a variable, 'form'. Within the macro, the 'form' variable (which is an FSForm object) is defined as None unless I access it using python expressions.
Can you show us two small snippets of example code that show both ways of working? cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
Floyd May wrote at 2006-3-30 10:06 -0600:
... Within the macro, the 'form' variable (which is an FSForm object) is defined as None unless I access it using python expressions.
Path expressions essentially use "restrictedTraverse" to locate the object identified by the path. This *IS* different from a sequence of attribute lookups in a Python expression. Do you get "None", when you use "restrictedTraverse" in the Python expression? Of course, this does not apply to direct "variable" access but only non trivial paths. With respect to "variable" access, both path and python expressions essentially use the same namespace (that of python expressions is a bit larger, but the names defined there have lower priority than that of the namespace part shared with path expressions). -- Dieter
participants (3)
-
Chris Withers -
Dieter Maurer -
Floyd May