equal
deleted
inserted
replaced
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 import time |
|
17 from bkmark import Bookmark |
|
18 import os |
|
19 |
|
20 def main(keywords, title, url, prefs): |
|
21 tmpl = Template("add_bk.tmpl", prefs) |
|
22 tmpl.set('ctitle', title) |
|
23 tmpl.set('curl', url) |
|
24 tmpl.set('desc', '') |
|
25 tmpl.set('bkid', -1) |
|
26 tmpl.set('Keywords', keywords) |
|
27 print tmpl.process() |
|
28 |
|
29 if (__name__ == "__main__"): |
|
30 form = cgi.FieldStorage() |
|
31 name = url = "" |
|
32 if form.has_key("ctitle"): |
|
33 name = form["ctitle"].value |
|
34 if form.has_key("curl"): |
|
35 url = form["curl"].value |
|
36 db = my_db.connect(os.environ["REMOTE_USER"]) |
|
37 kw = db.get_all_keywords()[1:] |
|
38 kw.sort(lambda l,r: cmp(l[1],r[1])) |
|
39 kw = map(lambda elem: { |
|
40 'id' : elem[0], |
|
41 'keyword' : elem[1], |
|
42 'checked' : 0 }, kw) |
|
43 main(kw, name, url, db.get_preferences()) |
|