add.py
branchxbelweb
changeset 42 6d31ed0f6ad3
parent 21 345ee7421989
child 47 2781ac85b807
equal deleted inserted replaced
41:7b7cd0e74ee3 42:6d31ed0f6ad3
     9 print "Content-type: text/html; charset=iso-8859-1;"
     9 print "Content-type: text/html; charset=iso-8859-1;"
    10 print
    10 print
    11 
    11 
    12 # import cgitb; cgitb.enable()
    12 # import cgitb; cgitb.enable()
    13 import cgi
    13 import cgi
    14 from htmltmpl import TemplateManager, TemplateProcessor
    14 from htmltmpl import TemplateManager
       
    15 from webutils import get_template_processor;
    15 import my_db
    16 import my_db
    16 import time
    17 import time
    17 from bkmark import Bookmark
    18 from bkmark import Bookmark
    18 import os
    19 import os
    19 
    20 
    20 def main(keywords, title, url):
    21 def main(keywords, title, url, prefs):
    21     tmpl = TemplateManager().prepare("add_bk.tmpl")
    22     tmpl = TemplateManager().prepare("add_bk.tmpl")
    22     tproc = TemplateProcessor()
    23     tproc = get_template_processor(prefs)
    23     tproc.set("pagetitle", os.environ["REMOTE_USER"]+"'s XBELWeb Edit Bookmark")
       
    24     tproc.set('ctitle', title)
    24     tproc.set('ctitle', title)
    25     tproc.set('curl', url)
    25     tproc.set('curl', url)
    26     tproc.set('desc', '')
    26     tproc.set('desc', '')
    27     tproc.set('bkid', -1)
    27     tproc.set('bkid', -1)
    28     tproc.set('Keywords', keywords)
    28     tproc.set('Keywords', keywords)
    40     kw.sort(lambda l,r: cmp(l[1],r[1]))
    40     kw.sort(lambda l,r: cmp(l[1],r[1]))
    41     kw = map(lambda elem: {
    41     kw = map(lambda elem: {
    42    	 'id' : elem[0],
    42    	 'id' : elem[0],
    43 	 'keyword' : elem[1],
    43 	 'keyword' : elem[1],
    44     	 'checked' : 0 }, kw)
    44     	 'checked' : 0 }, kw)
    45     main(kw, name, url)
    45     main(kw, name, url, db.get_preferences())