[Zope-CMF] simple (I think :-) TAL/python expression question
larry_prikockis@natureserve.org
larry_prikockis@natureserve.org
Tue, 10 Jun 2003 16:45:34 -0400
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C32F91.3DA6F0A0
Content-Type: text/plain;
charset="iso-8859-1"
thanks! ok... I knew it had to be simple... of course I feel a bit foolish
now :-)
-----Original Message-----
From: Sam Brauer [mailto:sam@webslingerz.com]
Sent: Tuesday, June 10, 2003 4:34 PM
To: gmane
Cc: zope-cmf@zope.org
Subject: Re: [Zope-CMF] simple (I think :-) TAL/python expression
question
gmane wrote:
> I have the following snippet of code:
> (the "nwType" and such relate to a javascript menu library I'm using)
>
> --------------
> <div nwType="menuComponent" width="150">
> <metal:block tal:repeat="item menu_items">
> <div tal:condition="python:item.folder_type == 'division'"
> nwType="menuNode" tal:attributes="dispText item/Title; action
> string:window.location='${portal_url}/${item/getId}';">
> </div>
> </metal:block>
> </div>
> ----------------
>
> my question is, how do I code the "python:item.folder_type == ????? "
line
> so that instead of the hard-coded 'division' string, I'm comparing against
a
> "tal:define=blah tab/id" statement earlier? Actually, I'm assuming I
need
> to make the defined variable global, but I can't come to grips with the
> syntax for the python expression.
>
> and of course, I realize this whole ugly ball of code probably needs to be
> moved out of the template and into a script... but I'm saving that for my
> next trick :-)
>
> thanks for any clues anyone can provide...
>
> Larry
>
>
You either need to define "blah" globally as you said, or define it in a
tag that surrounds the context where you want to refer to it:
<span tal:define="blah tab/id">
...
<div tal:condition="python:item.folder_type == blah">
...
</div>
...
</span>
In either case, your python expression would simply be:
item.folder_type == blah
>
>
>
> _______________________________________________
> Zope-CMF maillist - Zope-CMF@zope.org
> http://mail.zope.org/mailman/listinfo/zope-cmf
>
> See http://collector.zope.org/CMF for bug reports and feature requests
--
Sam Brauer
Systems Programmer
sam@webslingerZ.com
------_=_NextPart_001_01C32F91.3DA6F0A0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2653.12">
<TITLE>RE: [Zope-CMF] simple (I think :-) TAL/python expression =
question</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=3D2>thanks! ok... I knew it had to be simple... of =
course I feel a bit foolish now :-)</FONT>
</P>
<P><FONT SIZE=3D2>-----Original Message-----</FONT>
<BR><FONT SIZE=3D2>From: Sam Brauer [<A =
HREF=3D"mailto:sam@webslingerz.com">mailto:sam@webslingerz.com</A>]</FON=
T>
<BR><FONT SIZE=3D2>Sent: Tuesday, June 10, 2003 4:34 PM</FONT>
<BR><FONT SIZE=3D2>To: gmane</FONT>
<BR><FONT SIZE=3D2>Cc: zope-cmf@zope.org</FONT>
<BR><FONT SIZE=3D2>Subject: Re: [Zope-CMF] simple (I think :-) =
TAL/python expression</FONT>
<BR><FONT SIZE=3D2>question</FONT>
</P>
<BR>
<P><FONT SIZE=3D2>gmane wrote:</FONT>
<BR><FONT SIZE=3D2>> I have the following snippet of code:</FONT>
<BR><FONT SIZE=3D2>> (the "nwType" and such relate to a =
javascript menu library I'm using)</FONT>
<BR><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>> --------------</FONT>
<BR><FONT SIZE=3D2>> <div nwType=3D"menuComponent" =
width=3D"150"></FONT>
<BR><FONT SIZE=3D2>> <metal:block =
tal:repeat=3D"item menu_items"></FONT>
<BR><FONT =
SIZE=3D2>>  =
; <div tal:condition=3D"python:item.folder_type =3D=3D =
'division'"</FONT>
<BR><FONT SIZE=3D2>> nwType=3D"menuNode" =
tal:attributes=3D"dispText item/Title; action</FONT>
<BR><FONT SIZE=3D2>> =
string:window.location=3D'${portal_url}/${item/getId}';"></FONT>=
<BR><FONT =
SIZE=3D2>>  =
; </div></FONT>
<BR><FONT SIZE=3D2>> =
</metal:block></FONT>
<BR><FONT SIZE=3D2>> </div></FONT>
<BR><FONT SIZE=3D2>> ----------------</FONT>
<BR><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>> my question is, how do I code the =
"python:item.folder_type =3D=3D ????? " line</FONT>
<BR><FONT SIZE=3D2>> so that instead of the hard-coded 'division' =
string, I'm comparing against a</FONT>
<BR><FONT SIZE=3D2>> "tal:define=3Dblah tab/id" statement =
earlier? Actually, I'm assuming I need</FONT>
<BR><FONT SIZE=3D2>> to make the defined variable global, but I =
can't come to grips with the</FONT>
<BR><FONT SIZE=3D2>> syntax for the python expression.</FONT>
<BR><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>> and of course, I realize this whole ugly ball =
of code probably needs to be</FONT>
<BR><FONT SIZE=3D2>> moved out of the template and into a script... =
but I'm saving that for my</FONT>
<BR><FONT SIZE=3D2>> next trick :-)</FONT>
<BR><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>> thanks for any clues anyone can =
provide...</FONT>
<BR><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>> Larry</FONT>
<BR><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>> </FONT>
</P>
<P><FONT SIZE=3D2>You either need to define "blah" globally =
as you said, or define it in a </FONT>
<BR><FONT SIZE=3D2>tag that surrounds the context where you want to =
refer to it:</FONT>
</P>
<P><FONT SIZE=3D2><span tal:define=3D"blah =
tab/id"></FONT>
<BR><FONT SIZE=3D2> ...</FONT>
<BR><FONT SIZE=3D2> <div =
tal:condition=3D"python:item.folder_type =3D=3D =
blah"></FONT>
<BR><FONT SIZE=3D2> ...</FONT>
<BR><FONT SIZE=3D2> </div></FONT>
<BR><FONT SIZE=3D2> ...</FONT>
<BR><FONT SIZE=3D2></span></FONT>
</P>
<P><FONT SIZE=3D2>In either case, your python expression would simply =
be:</FONT>
<BR><FONT SIZE=3D2>item.folder_type =3D=3D blah</FONT>
</P>
<P><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>> =
_______________________________________________</FONT>
<BR><FONT SIZE=3D2>> Zope-CMF maillist - =
Zope-CMF@zope.org</FONT>
<BR><FONT SIZE=3D2>> <A =
HREF=3D"http://mail.zope.org/mailman/listinfo/zope-cmf" =
TARGET=3D"_blank">http://mail.zope.org/mailman/listinfo/zope-cmf</A></FO=
NT>
<BR><FONT SIZE=3D2>> </FONT>
<BR><FONT SIZE=3D2>> See <A HREF=3D"http://collector.zope.org/CMF" =
TARGET=3D"_blank">http://collector.zope.org/CMF</A> for bug reports and =
feature requests</FONT>
</P>
<BR>
<P><FONT SIZE=3D2>-- </FONT>
<BR><FONT SIZE=3D2>Sam Brauer</FONT>
<BR><FONT SIZE=3D2>Systems Programmer</FONT>
<BR><FONT SIZE=3D2>sam@webslingerZ.com</FONT>
</P>
</BODY>
</HTML>
------_=_NextPart_001_01C32F91.3DA6F0A0--