[Zope] DTML-WITH Problem

Dieter Maurer dieter@handshake.de
Tue, 18 Sep 2001 22:47:46 +0200 (CEST)


Jan Lentfer writes:
 > Ok, I searched the archives again and again and took a glance at Dieter 
 > Maurer's book and found that it seems to be a bigger problem to adress an 
 > object (in my case a folder) by a path (=string).
You found something like that in my book?

  Then, apparently, I need to change something.

  It is not a "bigger" problem to address an object!

  You use "Computed Attribute Access", "Computed Variable/Object Access"
  or "restrictedTraverse". All not too difficult....

 > Some of the solutions I found involved the use of "restrictedTraverse", so 
 > I played around with that for a while.
 > 
 > My site looks like that:
 > 
 > /
 > |-admin/---- managegallery.htm
 >        |
 >      galleries/ ---- gallery1/
 >                    ---- gallery2/
 > 
 > ......
 > 
 > in "managegallery.htm" I now have the following code:
 > 
 > <dtml-call expr="REQUEST.set ('working_folder', 'galleries.'+gallery_id)">
 >   <dtml-with expr="restrictedTraverse(_[working_folder])">
Here you use both "Computed Object Access" *AND* "restrictedTraverse".
Use just one, not both:

     <dtml-with expr="restrictedTraverse(working_folder)">
or
     <dtml-with expr="_.getitem(working_folder)">

You read in my book the difference between "_.getitem(...)",
and "_[...]"? You already understand why to use "getitem"
rather than subscription?



Dieter