1 #!/usr/bin/python |
|
2 |
|
3 import sys |
|
4 import traceback |
|
5 sys.path.insert(0, "/home/fabien/lib/python") |
|
6 sys.path.insert(0, "./lib") |
|
7 sys.stderr = sys.stdout |
|
8 |
|
9 print "Content-type: text/html; charset=iso-8859-1;" |
|
10 print |
|
11 |
|
12 # import cgitb; cgitb.enable() |
|
13 import cgi |
|
14 from templates import Template |
|
15 import my_db |
|
16 from bkmark import Bookmark |
|
17 from keywords import get_keywords |
|
18 import os |
|
19 |
|
20 def main(action, sel_keywords, keywords, prefs): |
|
21 tmpl = Template("kw_confirm.tmpl", prefs) |
|
22 tmpl.set("confirm_delete", action == 'delete') |
|
23 tmpl.set("confirm_merge", action == 'merge') |
|
24 tmpl.set("confirm_rename", action == 'rename') |
|
25 tmpl.set("action", action) |
|
26 tmpl.set("Selected", sel_keywords) |
|
27 tmpl.set("Keywords", keywords) |
|
28 print tmpl.process() |
|
29 |
|
30 if (__name__ == "__main__"): |
|
31 form = cgi.FieldStorage() |
|
32 db = my_db.connect(os.environ["REMOTE_USER"]) |
|
33 ids = get_keywords(form, 'kw') |
|
34 keywords = map(lambda e: { 'id': e[0], 'keyword': e[1]}, |
|
35 db.get_all_keywords()[1:]) |
|
36 keywords.sort(lambda x, y: cmp(x['keyword'],y['keyword'])) |
|
37 sel_keywords = filter(lambda e: e['id'] in ids, keywords) |
|
38 keywords = filter(lambda e: e['id'] not in ids, keywords) |
|
39 action = form['action'].value |
|
40 main(action, sel_keywords, keywords, db.get_preferences()) |
|
41 |
|