[Zope] Using a Python script inside a dtml-tree
Pierre Godefroy
pierre.godefroy@noos.fr
Sun, 06 Oct 2002 11:15:45 +0200
I have the following Python script, which works well (it gives the position=
=20
of an object in the form of a "nested numbered hierarchy", such as :=20
"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
----------------------------------------------------------------------------=
----------------------------
BUT, in its present form it only works for the object which is being called=
=20
directly by the user.
I would like to use it also in the framework of a dtml-tree, in order to=20
order to apply ot to each object iterated through the tree and displayed as=
=20
a menu item :
<dtml-tree>
<dtml-var my_python_script>
</dtml-tree>
Of course then, "context.REQUEST.PARENTS" is not good as it applies to the=
=20
main object being called, not to the successive objects which are being=20
retrieved recursively through the dtml-tree.
What should I do? How should I modify the script?
Thanking you all in advance,
Pierre
Pierre Godefroy
52 rue des Archives
75004 PARIS
FRANCE
T=E9l. : +33 (0)1 42 74 46 05