[Zope-DB] RE: [Zope] passing parameter problem
Laura McCord
Laura.McCord at doucet-austin.com
Thu Sep 16 12:35:14 EDT 2004
Yeah I am having a hard time with this.
I revised my script again using tuples() to access the value:
r = container.view_activity(SystemNetName =
SystemNetName).tuples()[0][0]
if r == 'active':
return r
else:
return 'failed'
it is still returning 'failed' even though if I print r it returns
active.
Somehow, it is not going through that if statement. Can the single
quotes cause a problem?
-Laura
-----Original Message-----
From: Alexis Roda [mailto:alexis.roda at urv.es]
Sent: Thursday, September 16, 2004 10:40 AM
To: Laura McCord
Subject: Re: [Zope] passing parameter problem
Laura McCord wrote:
> Ok, I think I know what my problem is:
>
> I tried revising the python script where I call the zsql method that
> looks up the value of Active_Inactive and pass the SystemNetName
> variable.
>
> status = context.view_activity(SystemNetName = SystemNetName) if
> status == 'active': return '#000'
> if status == 'inactive':
> return '#b7b7b7'
> else:
> return status
>
> It will always return the value of status because
> status = <Shared.DC.ZRDB.Results.Results instance at 0xb2d1512c>
> so how do I convert status into its true value which is active or
> inactive?
I think I don't understand.
view_activity is a ZSQL method, right? ZSQL Methods returns
Shared.DC.ZRDB.Results.Results instances, which are objects that behave
as a tuple of records, so status is not a record, is (something behaving
like) a tuple of records, it may be a tuple with just one record, but
still a tuple. status[0] is a "record". For example, if the sql query is
"select foo, bar from baz", you can do status[0].bar to get the bar
field from the first record and so on.
HTH
--
////
(@ @)
----------------------------oOO----(_)----OOo--------------------------
<> Ojo por ojo y el mundo acabara ciego
/\ Alexis Roda - Universitat Rovira i Virgili - Reus, Tarragona (Spain)
-----------------------------------------------------------------------
More information about the Zope-DB
mailing list