lib/actions/edit.py
author Fabien Ninoles <fabien@tzone.org>
Sun, 28 Dec 2008 15:21:49 -0500
changeset 64 f1b93ddec9e0
parent 57 31271426f879
permissions -rw-r--r--
More generic configuration.

#!/usr/bin/python

from templates import Template

def main(keywords, bk, prefs):
    tmpl = Template("add_bk.tmpl", prefs)
    tmpl.set('ctitle', bk.name)
    tmpl.set('curl', bk.url)
    tmpl.set('desc', bk.desc)
    tmpl.set('bkid', bk.id)
    tmpl.set('Keywords', keywords)
    print tmpl.process()

def do_it(action, db, prefs, form):
    id = int(form["id"].value)
    bk = db.get_bookmarks([id])[0]
    kw = db.get_all_keywords()[1:]
    kw.sort(lambda l,r: cmp(l[1],r[1]))
    (ids, kws) = apply(zip,db.get_keywords([id]))
    kw = map(lambda elem: {
   	 'id' : elem[0],
   	 'keyword' : elem[1],
	 'selected' : elem[0] in ids }, kw)
    main(kw, bk, prefs)