Basic object access question
Howdy, I'm sure this is explained any number of places, but I haven't found it. Given this layout, with Project and ImageFolder in my installation root; 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? Thanks, Kent
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!
Hi Kent, <dtml-with "ImageFolder"> <dtml-with "sub"> <dtml-with "sub2"> <dtml-var Image> </dtml-with> </dtml-with> </dtml-with> There are other ways. Please read http://www.zope.org/Documentation/ZopeBook/AdvDTML.stx for more information. HTH, - C On Mon, 2002-05-27 at 08:02, kent@springfed.com wrote:
Howdy,
I'm sure this is explained any number of places, but I haven't found it.
Given this layout, with Project and ImageFolder in my installation root;
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?
Thanks, Kent
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (3)
-
Chris McDonough -
Garikoitz Araolaza -
kent@springfed.com