[Zope] Calling form elements by name
Danny William Adair
Danny@Adair.net
Wed, 25 Oct 2000 22:00:25 +0200
Ok,
<dtml-let nameAsAString="'index_html'">
<dtml-var "_[nameAsAString]">
</dtml-let>
works alright, even my longer (using a TinyTablePlus)
------------------------------------------------
<dtml-in Items sort=Position>
<dtml-let Prefix="'FormElement_'"
thePos=Position
nameAsAString="Prefix+thePos">
<dtml-var nameAsAString><br>
<dtml-var "_['FormElement_1']"><br>
</dtml-let>
</dtml-in>
------------------------------------------------
will work(as expected), BUT:
------------------------------------------------
<dtml-in Items sort=Position>
<dtml-let Prefix="'FormElement_'"
thePos=Position
nameAsAString="Prefix+thePos">
<dtml-var nameAsAString><br>
<dtml-var "_['FormElement_1']"><br>
<dtml-var "_[nameAsAString]"><br>
</dtml-let>
</dtml-in>
------------------------------------------------
definitely won't, Key Error:
File /.../lib/python/DocumentTemplate/DT_In.py, line 691, in renderwob
(Object: Items)
File /.../lib/python/DocumentTemplate/DT_Let.py, line 147, in render
(Object: Prefix="'Service_'"
thePos=Position
nameAsAString="Prefix+thePos")
File /.../lib/python/DocumentTemplate/DT_Util.py, line 337, in eval
(Object: _[nameAsAString])
(Info: nameAsAString)
File <string>, line 0, in ?
File /.../lib/python/DocumentTemplate/DT_Util.py, line 163, in
careful_getitem
KeyError: (see above)
The string's content seems okay to me, so why can't I look up the object?
The namespace should be okay since I can call the request variables
_directly_.
What's wrong?
tia,
Danny
-----Ursprüngliche Nachricht-----
Von: Steve Drees [mailto:drees@the-bridge.net]
Gesendet: Mittwoch, 25. Oktober 2000 21:08
An: Danny@Adair.net
Betreff: RE: [Zope] Calling form elements by name
<dtml-let "nameAsAString = 'index_html'">
<dtml-var "_[nameAsAString]">
</dtml-let>
> -----Original Message-----
> From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Danny
> William Adair
> Sent: Wednesday, October 25, 2000 1:27 PM
> To: zope@zope.org
> Subject: [Zope] Calling form elements by name
>
>
> How can I render a REQUEST variable in DTML if I have its id as a string?
> I would like to construct its name as a string and then call the REQUEST
> variable by its name.
> (Meaning I will have to make sure such an object exists)
>
> tia,
>
> CU+Prost,
>
> Danny
>
> _______________________________________________
> 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 )
>
>