index.py
author fabien
Tue, 07 Oct 2003 12:53:05 -0400
branchxbelweb
changeset 39 d0d089958f7d
parent 38 c30e2402deca
child 41 7b7cd0e74ee3
permissions -rwxr-xr-x
[svn r1583] Update changelog.

#!/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, db.get_preferences())