[Zope] DTML Newbie: Using variable as an object in path?
Kevin Carlson
khcarlso@bellsouth.net
Thu, 9 Jan 2003 12:48:50 -0500
Since you are using a python expression, you must enclose the string in
quotes otherwise Zope tries to locate a variable named slashdot. Modify
your code as follows:
<dtml-let channel="'slashdot'">
<dtml-with "channels[channel]">
etc...
</dtml-with>
</dtml-let>
Looks a bit odd at first, but the purpose is to let the interpreter know
that you're passing in a string and not a reference to a variable.
Kevin
-----Original Message-----
From: Patrick Price [mailto:patrick@wvu.edu]
Sent: Thursday, January 09, 2003 11:22 AM
To: Kevin Carlson
Cc: Patrick Price; zope@zope.org
Subject: Re: [Zope] DTML Newbie: Using variable as an object in path?
I'm lost. I have a folder, channels, and inside that, an RDF Summary
object named slashdot:
<dtml-let channel="slashdot">
<dtml-with "channels[channel]">
etc...
</dtml-with>
</dtml-let>
This results in "Global name 'slashdot' is not defined."
An interesting aside: if I try <dtml-with "channels.[channel]"> the
source will refuse to save, I get "page not found" when I click Save
Changes.
What am I doing wrong?
-Patrick Price
Kevin Carlson wrote:
>You could accomplish the first by using:
>
> <dtml-with "a_folder_name[the_variable_name]">
> --Note it says "the_variable_name" and not "the_variable_value"
>
>Another way to set a variable within the current DTML is to use <dtml-let>.
>
>Hope that helps,
>
>Kevin
>
>-----Original Message-----
>From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of
>Patrick Price
>Sent: Wednesday, January 08, 2003 11:52 PM
>To: zope@zope.org
>Subject: [Zope] DTML Newbie: Using variable as an object in path?
>
>
>I'd like to set a variable in a DTML document, then call another DTML
>doc and use that variable as part of an object path:, eg:
>
><dtml-with a_folder_name.the_variable_value>
>
>so I can use different objects (files) by passing the filename in the
>variable.
>
>How can I do this?
>
>Also, is the correct way to set a DTML variable to use dtml-call
>REQUEST.set or is there another way?
>
>Thanks in advance,
> Patrick Price
>
>
>_______________________________________________
>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 )
>