Cleanup of old code, fixes some errors with folders view and make it a
standard action.
#!/usr/bin/python
from keywords import get_keywords, sort_keywords, set_selection
from templates import Template
def process_index(bk, kw, pref, status, status_msg):
tmpl = Template("dynamic.tmpl", pref, status, status_msg)
bk.sort(lambda x,y: cmp(x['name'],y['name']))
tmpl.set("Bookmarks", bk)
kw = sort_keywords(kw, pref)
tmpl.set("Keywords", kw)
tmpl.set("total", len(bk))
print tmpl.process()
def do_dynamic(db, prefs, form, status, status_msg):
if form:
selection = get_keywords(form, 'sel')
exclusion = get_keywords(form, 'exc')
else:
selection = exclusion = []
if len(selection) == 0:
keywords = set_selection(db, [], selection, exclusion)
exc = map(lambda e: int(e['id']), keywords[1:])
bookmarks = db.select_bookmarks([0], exc)
else:
bookmarks = db.select_bookmarks(selection, exclusion)
keywords = set_selection(db,
map(lambda e: e[0], bookmarks),
selection, exclusion)
total = len(bookmarks)
if len(bookmarks) > 0:
bookmarks = db.get_bookmarks(map(lambda x: x[0], bookmarks))
bookmarks = map(lambda bk: bk.dict(), bookmarks)
process_index(bookmarks, keywords[1:], prefs, status, status_msg)