index.py
author fabien
Tue, 07 Oct 2003 00:20:01 -0400
branchxbelweb
changeset 35 df0cc976f762
parent 32 10f57beae364
child 38 c30e2402deca
permissions -rwxr-xr-x
[svn r1579] Use of select in edit bookmark page too.

#!/usr/bin/python

import sys
import traceback
if (__name__ == '__main__'):
	sys.path.insert(0, "/home/fabien/lib/python")
	sys.path.insert(0, "./lib")
	sys.stderr = sys.stdout

	print "Content-type: text/html; charset=iso-8859-1;"
	print

# import cgitb; cgitb.enable()
import cgi
import my_db
from webutils import *

if (__name__ == "__main__"):
    form = cgi.FieldStorage()
    db = my_db.connect(environ["REMOTE_USER"])
    selection = get_keywords(form, 'sel')
    exclusion = get_keywords(form, 'exc')
    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)