0
|
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 htmltmpl import TemplateManager, TemplateProcessor
|
|
15 |
import my_db
|
|
16 |
import time
|
3
|
17 |
from bkmark import Bookmark
|
0
|
18 |
|
4
|
19 |
def main(keywords, title, url):
|
3
|
20 |
tmpl = TemplateManager().prepare("add_bk.tmpl")
|
|
21 |
tproc = TemplateProcessor()
|
4
|
22 |
tproc.set('ctitle', title)
|
|
23 |
tproc.set('curl', url)
|
3
|
24 |
tproc.set('Keywords', keywords);
|
0
|
25 |
print tproc.process(tmpl)
|
|
26 |
|
|
27 |
if (__name__ == "__main__"):
|
4
|
28 |
form = cgi.FieldStorage()
|
|
29 |
name = url = ""
|
|
30 |
if form.has_key("ctitle"):
|
|
31 |
name = form["ctitle"].value
|
|
32 |
if form.has_key("curl"):
|
|
33 |
url = form["curl"].value
|
3
|
34 |
db = my_db.connect()
|
|
35 |
kw = db.get_all_keywords()[1:]
|
|
36 |
kw.sort(lambda l,r: cmp(l[1],r[1]))
|
|
37 |
kw = map(lambda elem: { 'id' : elem[0], 'keyword' : elem[1] }, kw)
|
4
|
38 |
main(kw, name, url)
|