[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!&nbsp; 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>&gt; I have the following snippet of code:</FONT>
<BR><FONT SIZE=3D2>&gt; (the &quot;nwType&quot; and such relate to a =
javascript menu library I'm using)</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; --------------</FONT>
<BR><FONT SIZE=3D2>&gt; &lt;div nwType=3D&quot;menuComponent&quot; =
width=3D&quot;150&quot;&gt;</FONT>
<BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;metal:block =
tal:repeat=3D&quot;item menu_items&quot;&gt;</FONT>
<BR><FONT =
SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
; &lt;div tal:condition=3D&quot;python:item.folder_type =3D=3D =
'division'&quot;</FONT>
<BR><FONT SIZE=3D2>&gt; nwType=3D&quot;menuNode&quot; =
tal:attributes=3D&quot;dispText item/Title; action</FONT>
<BR><FONT SIZE=3D2>&gt; =
string:window.location=3D'${portal_url}/${item/getId}';&quot;&gt;</FONT>=

<BR><FONT =
SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
; &lt;/div&gt;</FONT>
<BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&lt;/metal:block&gt;</FONT>
<BR><FONT SIZE=3D2>&gt; &lt;/div&gt;</FONT>
<BR><FONT SIZE=3D2>&gt; ----------------</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; my question is, how do I code the =
&quot;python:item.folder_type =3D=3D&nbsp; ????? &quot; line</FONT>
<BR><FONT SIZE=3D2>&gt; so that instead of the hard-coded 'division' =
string, I'm comparing against a</FONT>
<BR><FONT SIZE=3D2>&gt; &quot;tal:define=3Dblah tab/id&quot; statement =
earlier?&nbsp;&nbsp; Actually, I'm assuming I need</FONT>
<BR><FONT SIZE=3D2>&gt; to make the defined variable global, but I =
can't come to grips with the</FONT>
<BR><FONT SIZE=3D2>&gt; syntax for the python expression.</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; and of course, I realize this whole ugly ball =
of code probably needs to be</FONT>
<BR><FONT SIZE=3D2>&gt; moved out of the template and into a script... =
but I'm saving that for my</FONT>
<BR><FONT SIZE=3D2>&gt; next trick :-)</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; thanks for any clues anyone can =
provide...</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; Larry</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
</P>

<P><FONT SIZE=3D2>You either need to define &quot;blah&quot; 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>&lt;span tal:define=3D&quot;blah =
tab/id&quot;&gt;</FONT>
<BR><FONT SIZE=3D2>&nbsp; ...</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; &lt;div =
tal:condition=3D&quot;python:item.folder_type =3D=3D =
blah&quot;&gt;</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ...</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; &lt;/div&gt;</FONT>
<BR><FONT SIZE=3D2>&nbsp; ...</FONT>
<BR><FONT SIZE=3D2>&lt;/span&gt;</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>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; =
_______________________________________________</FONT>
<BR><FONT SIZE=3D2>&gt; Zope-CMF maillist&nbsp; -&nbsp; =
Zope-CMF@zope.org</FONT>
<BR><FONT SIZE=3D2>&gt; <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>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; 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--