Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: DB

ZSql and evaluating the results for a 0 or 1 - Newbie help

 

 

Zope db RSS feed   Index | Next | Previous | View Threaded


Steven.Klass at smsc

Jul 21, 2006, 2:27 PM

Post #1 of 3 (1429 views)
Permalink
ZSql and evaluating the results for a 0 or 1 - Newbie help

Hi all,

I have a very simple thing I want to do... (yeah I know famous last
words). I am querying a mysql database and displaying the results.. Then
I decided that I want to get a bit fancier.. tal:content item/results
value is either a 1 or a 0.

If item/results is == 0 I want to display "Pass" in green.
If item/results is == 1 I want to display "Fail" in red.

Can someone please help the newbie out?


My document as it stands today..

====================================================

<h4 tal:define="global item python:container.metriX.RemotePush()"
tal:condition="not:item">There Are No Items meeting the query</h4>
<table class="sortable" id="rpush" summary="Remote Push"
tal:condition="item">
<tr>
<td width="20%">Update Time</td>
<td width="15%">Host</td>
<td width="15%">Update</td>
<td width="50%">Files</td>
<td width="2%">Attempts</td>
</tr>
<tbody tal:repeat="item python:container.metriX.RemotePush()">
<tr class="even" tal:condition="repeat/item/even">
<td tal:content="item/last_update">update</td>
<td tal:content="item/host">host</td>
<td tal:content="item/return_val">ret</td>
<td tal:content="item/results">pass</td>
<td tal:content="item/num_attempts">attempts</td>

</tr>
<tr class="odd" tal:condition="repeat/item/even">
<td tal:content="item/last_update">update</td>
<td tal:content="item/host">host</td>
<td tal:content="item/return_val">ret</td>
<td tal:content="item/results">results</td>
<td tal:content="item/num_attempts">attempts</td>
</tr>
</tbody>
</table>
comp.web.zope.database/


---

Steven M. Klass

Design Automation Manager

SMSC
3930 East Ray Road, Suite 200
Phoenix, Arizona 85044
(480) 704-7046 (Desk)
(480) 225-1112 (Mobile)
steven.klass [at] smsc


maciej.wisniowski at coig

Jul 21, 2006, 2:50 PM

Post #2 of 3 (1309 views)
Permalink
Re: ZSql and evaluating the results for a 0 or 1 - Newbie help [In reply to]

Is this really DB related? ;)

> If item/results is == 0 I want to display "Pass" in green.
> If item/results is == 1 I want to display "Fail" in red.

But you already have such clauses in your code. Try:

<span tal:condition="python: item['results']==0" class="green">Pass</span>
<span tal:condition="python: item['results']==1" class="red">Fail</span>

or if you have only two values (0 and 1):

<span tal:attributes="class python: item['results']==0 and 'green' or 'red'"
tal:content="python: item['results']==0 and 'Pass' or
'Fail'">Fail or Pass</span>

or... few other possibilities exists too.

I'm not sure whether 'item' is a dictionary so above code may fail on it.

--
Maciej Wisniowski
_______________________________________________
Zope-DB mailing list
Zope-DB [at] zope
http://mail.zope.org/mailman/listinfo/zope-db


Steven.Klass at smsc

Jul 21, 2006, 3:16 PM

Post #3 of 3 (1307 views)
Permalink
Re: ZSql and evaluating the results for a 0 or 1 - Newbie help [In reply to]

I apologize that this is not really db related. Thanks it worked
perfectly!!

---

Steven M. Klass

Design Automation Manager

SMSC
3930 East Ray Road, Suite 200
Phoenix, Arizona 85044
(480) 704-7046 (Desk)
(480) 225-1112 (Mobile)
steven.klass [at] smsc



Maciej Wisniowski <maciej.wisniowski [at] coig>
Sent by: zope-db-bounces [at] zope
07/21/06 02:50 PM

To
Steven Klass/SMSC [at] SMS
cc
zope-db [at] zope
Subject
Re: [Zope-DB] ZSql and evaluating the results for a 0 or 1 - Newbie help






Is this really DB related? ;)

> If item/results is == 0 I want to display "Pass" in green.
> If item/results is == 1 I want to display "Fail" in red.

But you already have such clauses in your code. Try:

<span tal:condition="python: item['results']==0" class="green">Pass</span>
<span tal:condition="python: item['results']==1" class="red">Fail</span>

or if you have only two values (0 and 1):

<span tal:attributes="class python: item['results']==0 and 'green' or
'red'"
tal:content="python: item['results']==0 and 'Pass' or
'Fail'">Fail or Pass</span>

or... few other possibilities exists too.

I'm not sure whether 'item' is a dictionary so above code may fail on it.

--
Maciej Wisniowski
_______________________________________________
Zope-DB mailing list
Zope-DB [at] zope
http://mail.zope.org/mailman/listinfo/zope-db

Zope db RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.