[Zope] Getting an object from its name
Rafael Cordones Marcos
rcm@bcnartdirecte.com
Fri, 22 Oct 1999 12:12:44 +0200
Hi,
I have
Folder
showImage
FolderA
index_html
figure1
figure2
...
figure3
FolderB
index_html
figure1
figure2
...
figure3
FolderC
...
...
The DTML method showImage contains:
-----------------
<div align="center">
<table cellpading="0" cellspacing="0" border="0">
<tr><td><img src="<dtml-var img>" width="400"></td>
<tr><td><p>**********</p></td>
</table>
</div>
-----------------
and the DTML document contains:
-------------------
<dtml-var "showImage(img = 'figure1')">
-------------------
What should I put in "************" to get the title of the figure?
I've tried:
----------------
<div align="center">
<table cellpading="0" cellspacing="0" border="0">
<tr><td><img src="<dtml-var img>" width="400"></td>
<tr><td><p><dtml-var "_.getattr(_.getitem(img, 'title'))"></p></td>
</table>
</div>
----------------
but I get a Error Type: KeyError Error Value: figure1
and also tried:
----------------
<div align="center">
<table cellpading="0" cellspacing="0" border="0">
<tr><td><img src="<dtml-var img>" width="400"></td>
<tr><td><p><dtml-with "img"><dtml-var title></dtml-with></p></td>
</table>
</div>
----------------
Error Type: KeyError Error Value: title
So my question is: given a string, how can I get the object (and its
attributes)? I've looked at the DTML guide and the ZQR but they only
provide the syntax to getitem, getattr, ... not enough for me :(
Any help will be very much appreciated.
Thanx
Rafa
--
Linux. The Choice of a GNU Generation! -> http://www.debian.org