Re: help on loop variables

James Abbatiello <[email protected]> Thu, 30 Jun 2011 19:21:34 -0400
Newsgroups gmane.comp.python.cheetah
Message-ID <[email protected]>
--===============2968667642243374441==
Content-Type: multipart/alternative; boundary=20cf3011dcc16f585104a6f62947

--20cf3011dcc16f585104a6f62947
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: quoted-printable

Odd, it worked for me in my tests.  What is the type of $cell in your
template?  Can you provide a minimal complete example?

--=20
James Abbatiello


On Thu, Jun 30, 2011 at 3:55 PM, Tim Arnold <[email protected]> wrote:

> thanks for the help, but that doesn't work either. (not even getVar).
> I think it's impossible to do this with Cheetah.
> I'm rewriting this particular template in simpletal.
>
> thanks,
> --Tim
> On Tue, Jun 28, 2011 at 9:55 PM, James Abbatiello <[email protected]>
> wrote:
> > Try
> >
> > #if $cell.get('isHeader', False)
> >
> > or
> >
> > #if $cell.has_key('isHeader') and $cell.isHeader
> >
> > --
> > James Abbatiello
> >
> >
> > On Tue, Jun 28, 2011 at 2:53 PM, Tim Arnold <[email protected]>
> wrote:
> >>
> >> As far as I can tell, it is impossible to use $varExists() inside a
> >> loop variable. So I'm asking for help on how to re-think my situation.
> >>
> >> First, here's what will not work in Cheetah. varExists is always false=
:
> >> #for $row in $here
> >>  <tr>
> >>  #for $cell in $row
> >>    #if $varExists('cell.isHeader') and $cell.isHeader
> >>    <th style=3D"$cell.style.inline">${cell}</th>
> >>
> >> Second, here is a similar template, but written in SimpleTal that does
> >> work:
> >> <metal:block tal:repeat=3D"cell row">
> >>    <th tal:condition=3D"cell/isHeader"
> >>           tal:attributes=3D"style cell/style/inline;
> >>           tal:content=3D"cell"></th>
> >> </metal:block>
> >>
> >> I have some table cells with a varying suite of attributes; where
> >> those attributes exist I want to use them, and of course I don=92t wan=
t
> >> to get an error when trying to use a non-existent attribute.
> >>
> >> Finally, my question:
> >> is there any way to accomplish this with a Cheetah template?
> >>
> >> thanks,
> >> --Tim Arnold
> >>
> >>
> >>
> -------------------------------------------------------------------------=
-----
> >> All of the data generated in your IT infrastructure is seriously
> valuable.
> >> Why? It contains a definitive record of application performance,
> security
> >> threats, fraudulent activity, and more. Splunk takes this data and mak=
es
> >> sense of it. IT sense. And common sense.
> >> http://p.sf.net/sfu/splunk-d2d-c2
> >> _______________________________________________
> >> Cheetahtemplate-discuss mailing list
> >> [email protected]
> >> https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
> >
> >
>

--20cf3011dcc16f585104a6f62947
Content-Type: text/html; charset=windows-1252
Content-Transfer-Encoding: quoted-printable

Odd, it worked for me in my tests.=A0 What is the type of $cell in your tem=
plate?=A0 Can you provide a minimal complete example?<br><br>-- <br>James A=
bbatiello<br><br><br><div class=3D"gmail_quote">On Thu, Jun 30, 2011 at 3:5=
5 PM, Tim Arnold <span dir=3D"ltr">&lt;<a href=3D"mailto:jtim.arnold@gmail.=
com">[email protected]</a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex;">thanks for the help, but that doesn&#39;t w=
ork either. (not even getVar).<br>
I think it&#39;s impossible to do this with Cheetah.<br>
I&#39;m rewriting this particular template in simpletal.<br>
<br>
thanks,<br>
<font color=3D"#888888">--Tim<br>
</font><div><div></div><div class=3D"h5">On Tue, Jun 28, 2011 at 9:55 PM, J=
ames Abbatiello &lt;<a href=3D"mailto:[email protected]">[email protected]</a=
>&gt; wrote:<br>
&gt; Try<br>
&gt;<br>
&gt; #if $cell.get(&#39;isHeader&#39;, False)<br>
&gt;<br>
&gt; or<br>
&gt;<br>
&gt; #if $cell.has_key(&#39;isHeader&#39;) and $cell.isHeader<br>
&gt;<br>
&gt; --<br>
&gt; James Abbatiello<br>
&gt;<br>
&gt;<br>
&gt; On Tue, Jun 28, 2011 at 2:53 PM, Tim Arnold &lt;<a href=3D"mailto:jtim=
[email protected]">[email protected]</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; As far as I can tell, it is impossible to use $varExists() inside =
a<br>
&gt;&gt; loop variable. So I&#39;m asking for help on how to re-think my si=
tuation.<br>
&gt;&gt;<br>
&gt;&gt; First, here&#39;s what will not work in Cheetah. varExists is alwa=
ys false:<br>
&gt;&gt; #for $row in $here<br>
&gt;&gt; =A0&lt;tr&gt;<br>
&gt;&gt; =A0#for $cell in $row<br>
&gt;&gt; =A0 =A0#if $varExists(&#39;cell.isHeader&#39;) and $cell.isHeader<=
br>
&gt;&gt; =A0 =A0&lt;th style=3D&quot;$cell.style.inline&quot;&gt;${cell}&lt=
;/th&gt;<br>
&gt;&gt;<br>
&gt;&gt; Second, here is a similar template, but written in SimpleTal that =
does<br>
&gt;&gt; work:<br>
&gt;&gt; &lt;metal:block tal:repeat=3D&quot;cell row&quot;&gt;<br>
&gt;&gt; =A0 =A0&lt;th tal:condition=3D&quot;cell/isHeader&quot;<br>
&gt;&gt; =A0 =A0 =A0 =A0 =A0 tal:attributes=3D&quot;style cell/style/inline=
;<br>
&gt;&gt; =A0 =A0 =A0 =A0 =A0 tal:content=3D&quot;cell&quot;&gt;&lt;/th&gt;<=
br>
&gt;&gt; &lt;/metal:block&gt;<br>
&gt;&gt;<br>
&gt;&gt; I have some table cells with a varying suite of attributes; where<=
br>
&gt;&gt; those attributes exist I want to use them, and of course I don=92t=
 want<br>
&gt;&gt; to get an error when trying to use a non-existent attribute.<br>
&gt;&gt;<br>
&gt;&gt; Finally, my question:<br>
&gt;&gt; is there any way to accomplish this with a Cheetah template?<br>
&gt;&gt;<br>
&gt;&gt; thanks,<br>
&gt;&gt; --Tim Arnold<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; ------------------------------------------------------------------=
------------<br>
&gt;&gt; All of the data generated in your IT infrastructure is seriously v=
aluable.<br>
&gt;&gt; Why? It contains a definitive record of application performance, s=
ecurity<br>
&gt;&gt; threats, fraudulent activity, and more. Splunk takes this data and=
 makes<br>
&gt;&gt; sense of it. IT sense. And common sense.<br>
&gt;&gt; <a href=3D"http://p.sf.net/sfu/splunk-d2d-c2" target=3D"_blank">ht=
tp://p.sf.net/sfu/splunk-d2d-c2</a><br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; Cheetahtemplate-discuss mailing list<br>
&gt;&gt; <a href=3D"mailto:[email protected]">C=
[email protected]</a><br>
&gt;&gt; <a href=3D"https://lists.sourceforge.net/lists/listinfo/cheetahtem=
plate-discuss" target=3D"_blank">https://lists.sourceforge.net/lists/listin=
fo/cheetahtemplate-discuss</a><br>
&gt;<br>
&gt;<br>
</div></div></blockquote></div><br>

--20cf3011dcc16f585104a6f62947--


--===============2968667642243374441==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
--===============2968667642243374441==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Cheetahtemplate-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss

--===============2968667642243374441==--