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

Pierre Godefroy pierre.godefroy@noos.fr
Wed, 09 Oct 2002 20:38:16 +0200


At 12:14 09/10/2002 +0200, you wrote:
Thank you Maik, but slicing the PARENTS list is not a solution : the=20
objects  processed through the dtml-tree may belong to entirely different=20
"PARENTS" lists : the crux of the problem is how can I access the PARENTS=20
list of objects which are not the current object (from which we acquire the=
=20
"context")? How can I access other "contexts"?

Thanks for any ideas,

Pierre

>maybe you should simply slice your PARENTS...
>
>examples (don't know what's the right "direction" for your problem, but=20
>you can try it for yourself):
>
>lll=3Dlen(context.REQUEST.PARENTS[:2])
>
>or
>
>lll=3Dlen(context.REQUEST.PARENTS[3:])
>
>cheers, maik

--=20

>Pierre Godefroy wrote:
>>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=20
>>earlier 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") :
>>--------------------------------------------------------------------------=
-------------------------=20
>>
>>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
>>--------------------------------------------------------------------------=
------------------------------=20
>>
>>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=20
>>not good as it applies to the main object being called, not to the=20
>>successive 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)?
>
>
>Maik Jablonski                 __o
>www.zfl.uni-bielefeld.de    _ \<_    Deutsche Zope User Group
>Bielefeld, Germany          (_)/(_)               www.dzug.org
>
>
>
>
>_______________________________________________
>Zope maillist  -  Zope@zope.org
>http://lists.zope.org/mailman/listinfo/zope
>**   No cross posts or HTML encoding!  **
>(Related lists - http://lists.zope.org/mailman/listinfo/zope-announce
>http://lists.zope.org/mailman/listinfo/zope-dev )

Pierre Godefroy
52 rue des Archives
75004 PARIS
FRANCE

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