<dtml-with> / <dtml-in> bug or mistake?
hi When I try somehting like this in a dtml-method: <dtml-with "projectxy.showContent.concepts"> <dtml-var template> </dtml-with> everything works fine. Also with <dtml-in>... When I instead try it like this (with <dtml-in> or <dtml-with>) with a folder which has a number in the id field, I recieve a syntax error! <dtml-with "projectxy.04templates.concepts"> <dtml-var template> </dtml-with> After removing the "", I recieve a Key Error: Error Type: KeyError Error Value: projectxy.04templates.concepts Is this a bug or a mistake of my own? regards ./simon
When I instead try it like this (with <dtml-in> or <dtml-with>) with a folder which has a number in the id field, I recieve a syntax error!
Everything in the double quotes is Python and in Python objects cannot begin with a number, in Zope they can. To get around this you can do: <dtml-with projectxy><dtml-with 04templates><dtml-with concepts> <dtml-var template> </dtml-with></dtml-with></dtml-with> or <dtml-with "restrictedTraverse('projectxy.04templates.concepts')"> <dtml-var template> </dtml-with> Cheers. -- Andy McKay
try also: <dtml-with expr="projectxy['04templates'].concepts"> ... </dtml-with> hth, -Casey On Thu, 2002-06-27 at 10:49, Andy McKay wrote:
When I instead try it like this (with <dtml-in> or <dtml-with>) with a folder which has a number in the id field, I recieve a syntax error!
Everything in the double quotes is Python and in Python objects cannot begin with a number, in Zope they can. To get around this you can do:
<dtml-with projectxy><dtml-with 04templates><dtml-with concepts> <dtml-var template> </dtml-with></dtml-with></dtml-with>
or
<dtml-with "restrictedTraverse('projectxy.04templates.concepts')"> <dtml-var template> </dtml-with>
Cheers. -- Andy McKay
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Simon Brun writes:
... I recieve a syntax error!
<dtml-with "projectxy.04templates.concepts"> <dtml-var template> </dtml-with> Python's attribute access syntax "obj.attr" requires "attr" to be a Python name. Python names consist of ASCII letters, digits and "_" and must not start with a digit. As "0" is a digit, you get a "SyntaxError".
Inside Zope, the name usually must not start with "_" either. Otherwise, you get an "Unauthorized" exception. Dieter
participants (4)
-
Andy McKay -
Casey Duncan -
Dieter Maurer -
Simon Brun