[Zope] Accessing Properties from dtml

Oliver Bleutgen Oliver Bleutgen <myzope@gmx.net>
Tue, 18 Sep 2001 19:10:22 +0200


> Hi

> I'm trying to access properties from dtml. Something like <dtml-var
> FolderA.FolderB.ItemA.PropertyA> works just fine. Now I want to use that
> functionality in a loop (simmilar):

> <dtml-in "objectItems()">
>   <dtml-var "'FolderA.FolderB.' + _['sequence-item'] + '.PropertyA'"><br>
> </dtml-in>

hi,

<dtml-var "FolderA.FolderB[_['sequence-item']].PropertyA"> 
should do it.

Surely someone else can elaborate better or more correct, but 
let me just say that the '.' as you used it in your working example 
is not part of an object id, it describes a python operation, 
the attribute lookup, i.e. a.b tells python to look up the attribute
b in the object a (where "looking up" is duty of a).

But

<dtml-var "_['FolderA.FolderB.' + _['sequence-item'] + '.PropertyA']"><br>

tries to lookup an object whose name is "FolderA.FolderB.." (as you wrote).

Don't know what exactly happens then, but it's clearly not what you want.

cheers,
oliver