lib/xbelweb.py
author fabien@tzone.org
Wed, 31 Dec 2008 00:00:09 -0500
changeset 68 c1f1491f098c
parent 67 652ff41518f3
child 74 6784c4350b41
permissions -rwxr-xr-x
Some small correction and update.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
a4c49a0c313b [svn r1527] Premi�re version.
fabien
parents:
diff changeset
     1
#!/usr/bin/python
a4c49a0c313b [svn r1527] Premi�re version.
fabien
parents:
diff changeset
     2
a4c49a0c313b [svn r1527] Premi�re version.
fabien
parents:
diff changeset
     3
import sys
a4c49a0c313b [svn r1527] Premi�re version.
fabien
parents:
diff changeset
     4
import cgi
a4c49a0c313b [svn r1527] Premi�re version.
fabien
parents:
diff changeset
     5
import my_db
47
2781ac85b807 [svn r1604] Implement default_view preferences, which move things around a lot.
fabien
parents: 41
diff changeset
     6
from os import environ
65
b975a3d7606a Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents: 58
diff changeset
     7
from actions import actions
67
652ff41518f3 Update index.py and config to use the right information.
fabien@tzone.org
parents: 65
diff changeset
     8
from config import CONFIG
0
a4c49a0c313b [svn r1527] Premi�re version.
fabien
parents:
diff changeset
     9
67
652ff41518f3 Update index.py and config to use the right information.
fabien@tzone.org
parents: 65
diff changeset
    10
def main():
652ff41518f3 Update index.py and config to use the right information.
fabien@tzone.org
parents: 65
diff changeset
    11
    sys.stderr = sys.stdout
652ff41518f3 Update index.py and config to use the right information.
fabien@tzone.org
parents: 65
diff changeset
    12
    print "Content-type: text/html; charset=iso-8859-1;"
652ff41518f3 Update index.py and config to use the right information.
fabien@tzone.org
parents: 65
diff changeset
    13
    print
0
a4c49a0c313b [svn r1527] Premi�re version.
fabien
parents:
diff changeset
    14
    form = cgi.FieldStorage()
67
652ff41518f3 Update index.py and config to use the right information.
fabien@tzone.org
parents: 65
diff changeset
    15
    debug = form.has_key('debug')
652ff41518f3 Update index.py and config to use the right information.
fabien@tzone.org
parents: 65
diff changeset
    16
    if debug:
57
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents: 47
diff changeset
    17
	sys.stderr = sys.stdout
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents: 47
diff changeset
    18
	print "<pre>"
65
b975a3d7606a Partial submission, to include tests.
Fabien Ninoles <fabien@tzone.org>
parents: 58
diff changeset
    19
    db = my_db.connect(CONFIG, environ["REMOTE_USER"])
47
2781ac85b807 [svn r1604] Implement default_view preferences, which move things around a lot.
fabien
parents: 41
diff changeset
    20
    prefs = db.get_preferences()
57
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents: 47
diff changeset
    21
    if form.has_key('action'):
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents: 47
diff changeset
    22
    	action = form['action'].value
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents: 47
diff changeset
    23
    else:
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents: 47
diff changeset
    24
    	action = 'default'
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents: 47
diff changeset
    25
    if action in actions.keys():
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents: 47
diff changeset
    26
    	actions[action](action, db, prefs, form)
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents: 47
diff changeset
    27
    else:
31271426f879 First change to use a common entry point.
fabien@tzone.org
parents: 47
diff changeset
    28
    	actions['default']('default', db, prefs, form)
67
652ff41518f3 Update index.py and config to use the right information.
fabien@tzone.org
parents: 65
diff changeset
    29
    if debug:
652ff41518f3 Update index.py and config to use the right information.
fabien@tzone.org
parents: 65
diff changeset
    30
    	print "</pre>"