[Zope] Accessing the PARENTS of the objects displayed by a DTML-tree

Pierre Godefroy pierre.godefroy@noos.fr
Wed, 09 Oct 2002 09:36:27 +0200


I am reformulating an earlier e-mail, as its wording might be confusing.
(I also gave it a sexier subject line... :>)

I have the following Python script, which works well, thanks to an earlier=
=20
suggestion made by Maik Jablonski
(it gives the position of an object inside Zope folder hierarchy in the=20
form of a "nested numbers", such as : "3.4.3.2.3") :
----------------------------------------------------------------------------=
-----------------------
from string import join

res=3D[]
lll=3Dlen(context.REQUEST.PARENTS)

for i in range(lll-1):
  xyz=3Dcontext.REQUEST.PARENTS[i].id
  a=3Dcontext.REQUEST.PARENTS[i+1].objectIds().index(xyz)
  res.append('.'+str(a+1))

res.reverse()
fullnumber=3Djoin(res)
print fullnumber

return printed
----------------------------------------------------------------------------=
----------------------------
My problem is : how could I apply a similar mechanism for the objects=20
displayed by a dtml-tree?

I would like to have something like :

1 : title
1.1 : title
1.2 : title
2 : title
2.1 : title
2.1.1 : title
2.1.2 : title


This could be obtained by :
<dtml-tree branches_expr=3D"objectValues(['Folder'])">
<dtml-var my_python_script><dtml-var title>
</dtml-tree>

BUT, of course then, "context.REQUEST.PARENTS" in my present script is not=
=20
good as it applies to the main object being called, not to the successive=20
folders which are being retrieved recursively through the dtml-tree.

I need to access successively the PARENTS hierarchy of these objects.

What should I do? Is there a solution? How should I modify the script (or=20
the DTML-tree itself)?

Thanking you all in advance,

Pierre

Pierre Godefroy
52 rue des Archives
75004 PARIS
FRANCE

T=E9l. : +33 (0)1 42 74 46 05