[Zope] accessing objects through variables

Geir Bækholt Hansen Geir B Hansen <geirh@funcom.com>
Fri, 12 May 2000 09:17:47 +0200


on Thursday, May 11, 2000 Mike Mikkelsen wrote :
MM> Hello all,

MM> Using DTML, not Python, is it possible to access an object using a variable
MM> holding the name of the object you want to access?

MM> Example:
MM> MainFolder
MM> |------DTMLdoc
MM> |------SubFolder
MM>         |------DTMLform
MM>         |------SubSubFolder1
MM>                 |------index_html
MM>         |------SubSubFolder2
MM>                 |------index_html

MM> If DTMLform calls DTMLdoc with a REQUEST variable set to the name
MM> "SubSubFolder1", how do you access index_html in SubSubFolder1 using that
MM> variable?

MM> TIA

If no subfolders were neccesary (for example accessing index_html in
SubFolder instead of SubSubFolder1) , you could access an object
with a string variable holding its id like this :

<dtml-var "_[variablename]">

the subfolder stuff makes it a bit more tricky, if that too
would be dynamic, but you could probably use another
string-variable to hold path-info..

perhaps something like (untested):


<dtml-with "_[pathInfoVar]">
<dtml-var "_[variablename]">
</dtml-with>


--
Geir Bækholt
web-developer/designer
geirh@funcom.com
http://www.funcom.com