[Zope] Zsql: how to test len of results?

Marc marcolinux@linuxbr.com.br
Mon, 20 May 2002 17:47:12 -0300


Hi...
How do I know the length of a Zsql method result?
preferebly from the Zsql method itself, so I can do a update and test
again for some results. 
What I really want is to garantee return results from  questions DB.
If userid is not answering already, get a new question.

I've tried the following but it refuses to work:
<dtml-var expr="len(sql_Get_question(user=AUTHENTICATED_USER))">
Zope say: 
global name 'len' is not defined


Here some pseudocode in python (I'd prefer dtml code ,though): 
Hope is not too confusing :)

# not eficient. Call function twice :(
#
if len (sql_Get_Question(userid)) < 1 : 
	sql_New_Question(userid)
return sql_Get_Question(userid).results


#or something like:
try:
	sql_Get_Question (userid)
except:
	sql_New_Question (userid)
finally:
	sql_Get_Question (userid)

Any help would be greatly apreciated. I'm totally lost here :(
Thanks in advance.