On 3/30/06, Jonathan Hayward http://JonathansCorner.com <[EMAIL PROTECTED]
> wrote:
I have the following method; I am suspicious of the last line.
What I want to do is build up a query to search for instances of the object "document" encapsulated by "document_table", and then get a cursor which I can use to move through the results. Is there a way I can get a cursor (presumably changing the last line), and call something like cursor.current_object() to get the object the cursor is over, and cursor.next_object() to move to the next one?
def database_search(self):
query = []
query.append( \ "SELECT document_table.* FROM document_table, histogram_table ")
where_specified = 0
if selected_section in sequence(sections):
restricted_section = selected_section
#elif selected_section in sequence(subsections):
#restricted_section = subsections[selected_section]
else:
if configuration.get_program_name() == "searchlog":
restricted_section = get_default_section()
else:
restricted_section = None
if restricted_section != None:
if where_specified:
query.append("WHERE ")
else:
where_specified = 1
query.append ("AND ")
query.append("section = '" + restricted_section + "' ")
debug_log("database_search query words following:")
for word in sequence(re.split ("\W+")
debug_log("database_search query word " + word)
if word != "":
if where_specified:
query.append("WHERE ")
else:
where_specified = 1
query.append("AND ")
query.append("document_table.html_name = " + \
"histogram_table.html_name AND histogram_table.word = '" + \
word + "' ")
query.append("SORT BY document_table.last_viewed DESC;")
cursor = document_table.select("".join(query)).execute().cursor()
--
++ Jonathan Hayward, [EMAIL PROTECTED]
** To see an award-winning website with stories, essays, artwork,
** games, and a four-dimensional maze, why not visit my home page?
** All of this is waiting for you at http://JonathansCorner.com
** If you'd like a Google Mail (gmail.com) account, please tell me!
--
++ Jonathan Hayward, [EMAIL PROTECTED]
** To see an award-winning website with stories, essays, artwork,
** games, and a four-dimensional maze, why not visit my home page?
** All of this is waiting for you at http://JonathansCorner.com
** If you'd like a Google Mail (gmail.com) account, please tell me!