lib/actions/edit.py
author fabien@tzone.org
Wed, 31 Dec 2008 00:00:09 -0500
changeset 68 c1f1491f098c
parent 57 31271426f879
permissions -rw-r--r--
Some small correction and update.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
57
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents:
diff changeset
     1
#!/usr/bin/python
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents:
diff changeset
     2
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents:
diff changeset
     3
from templates import Template
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents:
diff changeset
     4
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents:
diff changeset
     5
def main(keywords, bk, prefs):
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents:
diff changeset
     6
    tmpl = Template("add_bk.tmpl", prefs)
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents:
diff changeset
     7
    tmpl.set('ctitle', bk.name)
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents:
diff changeset
     8
    tmpl.set('curl', bk.url)
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents:
diff changeset
     9
    tmpl.set('desc', bk.desc)
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents:
diff changeset
    10
    tmpl.set('bkid', bk.id)
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents:
diff changeset
    11
    tmpl.set('Keywords', keywords)
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents:
diff changeset
    12
    print tmpl.process()
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents:
diff changeset
    13
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents:
diff changeset
    14
def do_it(action, db, prefs, form):
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents:
diff changeset
    15
    id = int(form["id"].value)
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents:
diff changeset
    16
    bk = db.get_bookmarks([id])[0]
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents:
diff changeset
    17
    kw = db.get_all_keywords()[1:]
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents:
diff changeset
    18
    kw.sort(lambda l,r: cmp(l[1],r[1]))
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents:
diff changeset
    19
    (ids, kws) = apply(zip,db.get_keywords([id]))
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents:
diff changeset
    20
    kw = map(lambda elem: {
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents:
diff changeset
    21
   	 'id' : elem[0],
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents:
diff changeset
    22
   	 'keyword' : elem[1],
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents:
diff changeset
    23
	 'selected' : elem[0] in ids }, kw)
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents:
diff changeset
    24
    main(kw, bk, prefs)