def main():
"""Program entry function."""
# XXX: Stupid Apache on shrapnel has TZ set to US/Eastern, no idea why!
os.environ['TZ'] = 'Eire'
print("Content-type: text/html")
print()
atexit.register(shutdown)
# Sets up an exception handler for uncaught exceptions and saves
# traceback information locally.
#
cgitb.enable(logdir='%s/tracebacks' % os.getcwd())
global form
form = cgi.FieldStorage()
opt.mode = form.getfirst('mode')
if opt.mode not in cmds:
opt.mode = 'card'
opt.action = form.getfirst('action')
# XXX remove usr.override
# usr.override = opt.override = form.getfirst('override') == '1'
opt.override = form.getfirst('override') == '1'
# Start HTML now only for modes that print output *before* html_form is
# called (which calls start_html itself). We delay the printing of the
# header for all other modes as mode switching may occur (e.g.
# cardid <-> add/renew).
#
if opt.mode in cmds_noform or (opt.mode in cmds_custom and opt.action):
html_start()
global udb
udb = RBUserDB()
udb.setopt(opt)
# Open database and call function for specific command only if action
# is required or the command needs no user input (i.e. no blank form
# stage).
#
if opt.mode in cmds_noform or opt.action:
try:
udb.connect()
except ldap.LDAPError as err:
error(err, 'Could not connect to user database')
# not reached
try:
eval(opt.mode + '()')
except (ldap.LDAPError, RBError) as err:
error(err)
# not reached
html_form()
sys.exit(0)
评论列表
文章目录