[Zope] [Tree tag] Influencing the tree using the tree-s or tree-e cookie

Kamon Ayeva kamon.ayeva@experts-md.com
Tue, 27 Feb 2001 16:47:02 +0100


C'est un message de format MIME en plusieurs parties.

------=_NextPart_000_0009_01C0A0DC.E8F2CF10
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi,

I have searched the lists archive and did not found a solution to my =
problem.
I want to force a tree hierarchy using dtml-tree to expand a specific =
branch when it is rendered the first time.
I use the following Python code borrowed from TreeTag.py (encode_seq() ) =
to encode the 'id' of the tree item where I want the tree to be opened :

from string import join, split, rfind, find, translate
from urllib import quote, unquote
from zlib import compress, decompress
from binascii import b2a_base64, a2b_base64

tbl=3Djoin(map(chr, range(256)),'')
tplus=3Dtbl[:ord('+')]+'-'+tbl[ord('+')+1:]
tminus=3Dtbl[:ord('-')]+'+'+tbl[ord('-')+1:]

state=3Dcompress(str([id]))

l=3Dlen(state)
if l > 57:
    states=3D[]
    for i in range(0,l,57):
        states.append(b2a_base64(state[i:i+57])[:-1])
    state=3Djoin(states,'')
else:
    state=3Db2a_base64(state)[:-1]

l=3Dfind(state,'=3D')
if l >=3D 0:
    state=3Dstate[:l]
    state=3Dtranslate(state, tplus)

return state


***********************************************
The dtml-tree that I want to manipulate is something like :

<dtml-let id=3D"''">
   <dtml-tree id assume_children=3Dyes id=3Did =
branches_expr=3D"an_external_method(PARENT=3Did, USER=3DUSER)"> =20
        <dtml-var title>
    </dtml-tree>
</dtml-let>

The problem is that when I display the value returned by this Python =
code for a given 'id' and compare it to the value of 'tree-e' in the =
REQUEST, they don't match. And I expect them to match.
Can someone give me some lights ? Is my problem related to cookies or is =
it my encoding function that is used correctly ?
 =20
Many thanks,
Kamon
Experts-MD.com

------=_NextPart_000_0009_01C0A0DC.E8F2CF10
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.3018.900" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I have searched the lists archive and =
did not found=20
a solution to my problem.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I want to force a tree hierarchy using =
dtml-tree to=20
expand a specific branch when it is rendered the first =
time.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I use the following Python code =
borrowed from=20
TreeTag.py (encode_seq() ) to encode the 'id' of the tree&nbsp;item =
where I want=20
the tree to be opened&nbsp;:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>from string import join, split, rfind, =
find,=20
translate<BR>from urllib import quote, unquote<BR>from zlib import =
compress,=20
decompress<BR>from binascii import b2a_base64, a2b_base64</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>tbl=3Djoin(map(chr,=20
range(256)),'')<BR>tplus=3Dtbl[:ord('+')]+'-'+tbl[ord('+')+1:]<BR>tminus=3D=
tbl[:ord('-')]+'+'+tbl[ord('-')+1:]</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial =
size=3D2>state=3Dcompress(str([id]))</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>l=3Dlen(state)<BR>if l &gt; =
57:<BR>&nbsp;&nbsp;&nbsp;=20
states=3D[]<BR>&nbsp;&nbsp;&nbsp; for i in=20
range(0,l,57):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
states.append(b2a_base64(state[i:i+57])[:-1])<BR>&nbsp;&nbsp;&nbsp;=20
state=3Djoin(states,'')<BR>else:<BR>&nbsp;&nbsp;&nbsp;=20
state=3Db2a_base64(state)[:-1]</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>l=3Dfind(state,'=3D')<BR>if l &gt;=3D=20
0:<BR>&nbsp;&nbsp;&nbsp; state=3Dstate[:l]<BR>&nbsp;&nbsp;&nbsp;=20
state=3Dtranslate(state, tplus)</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>return state</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>***********************************************</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>The dtml-tree that I want to manipulate =
is=20
something like :</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;dtml-let =
id=3D"''"&gt;<BR>&nbsp;&nbsp;=20
&lt;dtml-tree id assume_children=3Dyes id=3Did=20
branches_expr=3D"an_external_method(PARENT=3Did, USER=3DUSER)"&gt;&nbsp; =

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &lt;dtml-var=20
title&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;/dtml-tree&gt;<BR>&lt;/dtml-let&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>The problem is that when I display the =
value=20
returned by this Python code for a given&nbsp;'id' and compare it =
to&nbsp;the=20
value of 'tree-e' in the REQUEST, they don't match. And I expect them to =

match.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Can someone give me some lights&nbsp;? =
Is my=20
problem related to cookies or is it my encoding function that is used =
correctly=20
?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Many thanks,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Kamon</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>Experts-MD.com</FONT></DIV></BODY></HTML>

------=_NextPart_000_0009_01C0A0DC.E8F2CF10--