[Zope-DB] python script calls zsql method need to compare values

Charlie Clark charlie at begeistert.org
Thu Sep 16 12:43:14 EDT 2004


Hi Laura,

this looks suspiciously like you want to set some HTML colours as a result 
of your enquiry. I suggest you simplify things a bit and use a CSS class.

results = context.myZSQL(item=value)
if len(results):
	return results[0].status
else:
	return "error"

Note that it is generally possible to do this directly in a PageTemplate 
without having to call a script.

<body tal:define="status python: context.myZSQL[0].status or 'error'">

<p tal:attributes="class status" tal:content="status"></p>
</body>

Good luck

Charlie

On 2004-09-16 at 17:38:41 [+0200], Laura McCord 
<Laura.McCord at doucet-austin.com> wrote:
> Hi,
> 
>  I am having a problem compraing the value that is returned by a zsql
> method.
> This is what I have so far:
> 
> status = context.view_activity(SystemNetName = SystemNetName)
> if status == 'active':
>  return '#000'
> if status == 'inactive':
>  return '#b7b7b7'
> else:
>  return status
> 
> Naturally, it is going to return status everytime because status is
> equal
> to <Shared.DC.ZRDB.Results.Results instance at 0xb2aa806c>
> 
> So, how to I compare it's actual value?


More information about the Zope-DB mailing list