index.py
branchxbelweb
changeset 13 7357230539d2
parent 9 896b7c6de627
child 15 574631f841c3
--- a/index.py	Wed Sep 24 16:44:09 2003 -0400
+++ b/index.py	Wed Sep 24 17:19:52 2003 -0400
@@ -31,6 +31,7 @@
 		chk = key[0] in sel
 		res.append({'id':key[0],
 			'keyword': key[1],
+			'count' : key[2],
 			'checked' : chk})
 	res.sort(lambda l,r: cmp(l["keyword"],r["keyword"]))
 	return res
@@ -38,18 +39,21 @@
 def get_curl():
 	return urljoin( 'http://' + environ["HTTP_HOST"] + environ["REQUEST_URI"], 'add.py')
 
-def main(bk, kw, curl):
+def main(bk, kw, curl, total):
     tmpl = TemplateManager().prepare("index.tmpl")
     tproc = TemplateProcessor()
     tproc.set("Bookmarks", bk)
     tproc.set("Keywords", kw)
     tproc.set("curl", curl)
+    tproc.set("total", total)
     print tproc.process(tmpl)
 
 if (__name__ == "__main__"):
     form = cgi.FieldStorage()
     db = my_db.connect()
-    keywords = db.get_all_keywords()[1:]
+    keywords = db.get_all_keywords()
+    total = keywords[0][2]
+    keywords = keywords[1:]
     selection = get_selection(form)
     if selection[0] == 0:
     	exc = map(lambda e: int(e[0]), keywords)
@@ -61,4 +65,4 @@
     	bookmarks = db.get_bookmarks(map(lambda x: x[0], bookmarks))
     bookmarks = map(lambda bk: bk.dict(), bookmarks)
     curl = get_curl();
-    main(bookmarks, keywords, curl)
+    main(bookmarks, keywords, curl, total)