[Zope] referencing title value as a var name
Casey Duncan
cduncan@kaivo.com
Tue, 14 Aug 2001 08:51:57 -0600
Kerekes Lajos wrote:
>
> Very special thaks. It is work.
> The last question.
> I want to put the "state sring" files under a
> folder named state. How can I reach the files in this case.
> I tried <dtml-with state> but still give NameError, it doesnt
> find the file named 0, 1, 2.
>
> Thanks:
>
> Lajos
No problem, just use this instead:
<dtml-var expr="state[_.str(STATE)]">
I would recommend wrapping this in a try statement so that it doesn't
blow up if the value returned is invalid, something like:
<dtml-try>
<dtml-var expr="state[_.str(STATE)]">
<dtml-except KeyError>
The state value &dtml-STATE; is invalid.
</dtml-try>
hth,
--
| Casey Duncan
| Kaivo, Inc.
| cduncan@kaivo.com
`------------------>