Select Failing

8 views
Skip to first unread message

Bill Huba

unread,
Nov 21, 2009, 3:17:02 PM11/21/09
to buzhug
I'm having trouble using the select method in a CGI script. I have
TS_Base instance named "db" opened. I can iterate through it using
list comprehension but select() returns a blank list every time. For
example, there's a field named "priority" with an int type. Doing:

print db.select(['priority'], priority = 5)

gives me [] on the webpage, while doing the same thing from a Python
shell returns the correct information. However, doing:

print [r for r in db if r.priority == 5]

displays the record in both the shell and webpage. Am I doing
something wrong here or is this a bug? I would just use the list
comprehension method, but I need to do some complex regex matchind and
would rather use the faster select() if I can.

Pierre Quentel

unread,
Nov 23, 2009, 3:33:54 AM11/23/09
to buzhug
Hello,
It's not easy to answer without a little more information on the CGI
script. Can it be related to a type conversion ? Perhaps you call
select() with a parameter passed as a string and it should be
converted to an int ?

- Pierre

Bill Huba

unread,
Nov 23, 2009, 2:20:16 PM11/23/09
to buzhug
Thanks for the reply,

After playing around with it for a while, I discovered my problem. The
object returned by the select() method doesn't display in a web
browser. However, using the fields within that works. So with my
example from before,

print db.select(['priority'], priority = 5)

will print an empty list. But doing:

set = db.select(['priority'], priority = 5)
for record in set:
print record.priority

works perfectly.

Jim Eggleston

unread,
Nov 23, 2009, 2:56:08 PM11/23/09
to buz...@googlegroups.com
Off topic, but thought I should point it out: "set" became a key word in Python 2.6 and 3.x, so best not to use it as a variable name.

Cheers,
Jim




2009/11/24 Bill Huba <bill...@gmail.com>
Reply all
Reply to author
Forward
0 new messages