Overview:
Implement user's request: save query on demand
a) Add to TKO greed view a form containing button [SaveQuery] and edit control for optional comments
b) On saveQuery request TKO make sure that user's cookies contain a unique user's id
c) ... and then write into table query_history in TKO: time stamp, comment, uid, url of the query
d) Make sure user can read saved queries back ( can read only his/her own queries )
compose_query.cgi - added a form that supports user's request to save cu rrent query
save_query.cgi - saves the query
query_history.cgi - shows saved queries by this user
unique_cookie.py - common cookie related function: set/get user's unique id
006_add_table_query_history.py - database migration. New table introduce d for query history.
From: vsamarsk@google.com
git-svn-id: http://test.kernel.org/svn/autotest/trunk@1533 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/tko/query_history.cgi b/tko/query_history.cgi
new file mode 100644
index 0000000..a399124
--- /dev/null
+++ b/tko/query_history.cgi
@@ -0,0 +1,40 @@
+#!/usr/bin/python
+
+import sys, os
+import MySQLdb
+import urllib, db, unique_cookie
+
+def body():
+ db_obj = db.db()
+ uid = unique_cookie.unique_id('tko_history')
+ condition = "uid='%s'" % uid
+ where = (condition,[])
+ try:
+ rows = db_obj.select("time_created,user_comment,url",
+ "query_history", where)
+ except MySQLdb.ProgrammingError, err:
+ print err
+ rows = ()
+
+ for row in rows:
+ (time_created, user_comment, tko_url) = row
+ print "<hr>"
+ print time_created + " "*3
+ print user_comment + "<br>"
+ print '<a href="%s">%s</a>' % (tko_url, tko_url)
+
+
+def main():
+ print "Content-type: text/html\n"
+ print
+ # create the actual page
+ print '<html><head><title>'
+ print 'History of TKO usage'
+ print '</title></head><body>'
+ body()
+ print '</body></html>'
+
+
+main()
+
+