15
|
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
|
|
17 |
|
|
18 |
def main(keyword, id, keywords):
|
|
19 |
tmpl = TemplateManager().prepare("edit_kw.tmpl")
|
|
20 |
tproc = TemplateProcessor()
|
|
21 |
tproc.set('keyword', keyword)
|
|
22 |
tproc.set('id', id)
|
|
23 |
tproc.set('Keywords', keywords)
|
|
24 |
print tproc.process(tmpl)
|
|
25 |
|
|
26 |
if (__name__ == "__main__"):
|
|
27 |
form = cgi.FieldStorage()
|
|
28 |
id = int(form["id"].value)
|
|
29 |
db = my_db.connect()
|
|
30 |
name = db.get_keyword(id)
|
|
31 |
kw = db.get_all_keywords()[1:]
|
|
32 |
kw.sort(lambda l,r: cmp(l[1],r[1]))
|
|
33 |
kw = map(lambda elem: {
|
|
34 |
'id' : elem[0],
|
|
35 |
'keyword' : elem[1] }, kw)
|
|
36 |
main(name, id, kw)
|