diff -r c763c420cbfc -r 896b7c6de627 edit.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/edit.py Wed Sep 24 15:48:47 2003 -0400 @@ -0,0 +1,41 @@ +#!/usr/bin/python + +import sys +import traceback +sys.path.insert(0, "/home/fabien/lib/python") +sys.path.insert(0, "./lib") +sys.stderr = sys.stdout + +print "Content-type: text/html; charset=iso-8859-1;" +print + +# import cgitb; cgitb.enable() +import cgi +from htmltmpl import TemplateManager, TemplateProcessor +import my_db +import time +from bkmark import Bookmark + +def main(keywords, bk): + tmpl = TemplateManager().prepare("add_bk.tmpl") + tproc = TemplateProcessor() + tproc.set('ctitle', bk.name) + tproc.set('curl', bk.url) + tproc.set('desc', bk.desc) + tproc.set('bkid', bk.id) + tproc.set('Keywords', keywords) + print tproc.process(tmpl) + +if (__name__ == "__main__"): + form = cgi.FieldStorage() + id = int(form["id"].value) + db = my_db.connect() + bk = db.get_bookmarks([id])[0] + kw = db.get_all_keywords()[1:] + kw.sort(lambda l,r: cmp(l[1],r[1])) + (ids, kws) = apply(zip,db.get_keywords(id)) + kw = map(lambda elem: { + 'id' : elem[0], + 'keyword' : elem[1], + 'checked' : elem[0] in ids }, kw) + main(kw, bk)