11 print |
11 print |
12 |
12 |
13 # import cgitb; cgitb.enable() |
13 # import cgitb; cgitb.enable() |
14 import cgi |
14 import cgi |
15 import my_db |
15 import my_db |
16 from webutils import * |
16 from os import environ |
|
17 from webutils import load_index |
17 |
18 |
18 if (__name__ == "__main__"): |
19 if (__name__ == "__main__"): |
19 form = cgi.FieldStorage() |
20 form = cgi.FieldStorage() |
20 db = my_db.connect(environ["REMOTE_USER"]) |
21 db = my_db.connect(environ["REMOTE_USER"]) |
21 selection = get_keywords(form, 'sel') |
22 prefs = db.get_preferences() |
22 exclusion = get_keywords(form, 'exc') |
23 load_index(db, prefs, form) |
23 if len(selection) == 0: |
|
24 keywords = set_selection(db, [], selection, exclusion) |
|
25 exc = map(lambda e: int(e['id']), keywords[1:]) |
|
26 bookmarks = db.select_bookmarks([0], exc) |
|
27 else: |
|
28 bookmarks = db.select_bookmarks(selection, exclusion) |
|
29 keywords = set_selection(db, |
|
30 map(lambda e: e[0], bookmarks), |
|
31 selection, exclusion) |
|
32 total = len(bookmarks) |
|
33 if len(bookmarks) > 0: |
|
34 bookmarks = db.get_bookmarks(map(lambda x: x[0], bookmarks)) |
|
35 bookmarks = map(lambda bk: bk.dict(), bookmarks) |
|
36 process_index(bookmarks, keywords[1:], db.get_preferences()) |
|