[Zope] Computed attribute access (was: [Zope] dtml-with syntax question)

Dieter Maurer dieter@handshake.de
Thu, 12 Oct 2000 23:20:37 +0200 (CEST)


Geoffrey L. Wright writes:
 > I think I am finally getting a decent handle on namespace issues in
 > Zope, and I can now with the dtml-with tag with reasonable efficacy in
 > simple situations. But I have run into something of a brick wall on
 > one issue.
 > 
 > What I would like to be able to do is something like this:
 > 
 > <dtml-with objectName1>
 > 	<dtml-var attribute1>
 > 	<dtml-var attribute2>
 > 	<dtml-var attribute3>
 > 	<dtml-with folder.subFolder.objectName2>
 > 		   <dtml-var attribute1>
 > 	</dtml-with>
 > </dtml-with>
 > 
 > Where objectName2 is actually an attribute of objectName1.
It seems (though it is not clear) that you want a
computed attribute access?

   Your "objectName2" is an attribute of "objectName1"
   and contains the "id" of an object in "folder.subfolder"?

Then, you use "_.getattr". That's for accessing an attribute
you have the name for (and the name is not constant).

In your case, you would use it as:

	<dtml-with "_.getattr(folder.subFolder,objectName2)">


Dieter