[Zope] DTML-WITH Problem
Jan Lentfer
Jan.Lentfer@web.de
Mon, 17 Sep 2001 20:30:02 +0200
At 19:23 17.09.2001 +0200, you wrote:
>Take a look at your zope online help, you find it in the ZMI, under
>Zope Help/Api Reference/ObjectManagerItem:
>
>
>restrictedTraverse(path, default=None):
> Return the object obtained by traversing the given path from the object
> on which the method was called, performing security checks along the way.
>
> If an object is not found then the default argument will be returned.
>
>
>So the first call should set working_folder to
>'galleries/'+gallery_id
>'/' instead of '.' - it's literally the path!
>
>Be aware that restrictedTraverse is a method of an ObjectManagerItem,
>so that
>admin.restrictedTraverse('galleries/gallerie1') ==
>admin.galleries.restrictedTraverse('gallerie1')
>i.e. you call it on another object.
>
>restrictedTraverse also does acquisition wrapping, ie
>admin.restrictedTraverse('galleries/gallery1/gallery2').aq_parent.title_or_id()
>== 'gallerie1'
>while
>admin.restrictedTraverse('galleries/gallery2').aq_parent.title_or_id() ==
>'galleries'
>
>You can also traverse down from the root folder, in order to rule out
>surprises:
>restrictedTraverse('/admin/galleries/gallery1')
>
>
>
>cheers,
>oliver
Thanks a lot, I got it working now!
Just in case someone runs into the same problems sometime I want to post
the code I use now.
----------
<dtml-call expr="REQUEST.set ('working_folder', gallery_id)">
<dtml-with expr="galleries.restrictedTraverse([working_folder])">
<dtml-in expr="objectValues('Image')" sort=bobobase_modification_time
reverse>
<dtml-var title><BR>
</dtml-in>
</dtml-with>
------------
Maybe this will provide help to someone else in the future
Now, one last question (Well, maybe not THE LAST ;-) ): Where the heck can
one find stuff like that? I mean where can I learn that?
Is that Python already and I should finally open up my Python book?
Again, many thanks,
Jan
Jan@Mountainbikehq.de
http://www.MountainbikeHQ.de - Your home for DH, DS and CC Mountainbiking