[Zope] Basic object access question
Garikoitz Araolaza
gari@eibar.org
Mon, 27 May 2002 16:34:46 +0200
At 14:02 27/05/02, kent@springfed.com wrote:
>Project
> sub
> sub2
>ImageFolder
> sub
> sub2 - Image
>
>a DTML Document in Project/sub/sub2 contains;
><dtml-var /ImageFolder/sub/sub2/Image>
>
>I get a KeyError
>
>What am I missing here, where is the explanation?
You are missing that when you type:
<dtml-var something>
you are really meaning:
<dtml-var expr="something">
where everything between quotes " " is a Python expression.
It is true that Zope maps URLs to
objects ( /ImageFolder/sub/sub2/Image to ImageFolder.sub.sub2.Image )
but in this case you have to express it with the Python syntax.
So, <dtml-var expr="ImageFolder.sub.sub2.Image"> should work.
You can leave aside expr= too, so:
<dtml-var "ImageFolder.sub.sub2.Image"> should be the easiest way to do it.
But warning:
If your image's ID is like: Image.jpg or Image.gif, you should
understand that Zope will try to find a property called jpg or gif within
an object called Image, so, to avoid it, your new syntax should be:
<dtml-var "ImageFolder.sub.sub2['Image.gif']">
Gari
_________________________________________________________
Aurki Euskara hutsezko bilatzailea
http://www.aurki.com
Zure laguntza behar dugu. Egin zaitez editore!