[SNIP]
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])"> <dtml-in expr="objectValues('Image')" sort=bobobase_modification_time reverse> <dtml-var title><BR> </dtml-in> </dtml-with>
Which gives me a KeyError, referencing an nonexistent object or variable. Does anyone have an idea what is still wrong with my code? I mean *to me* it looks like I at least was able to do the conversion from string to object, right? And now there's a problem that the object can't be found - for whatever reason.
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
participants (1)
-
Oliver Bleutgen