53
52
# Check req.app to see if it is valid. 404 if not.
54
53
if req.app is not None and req.app not in conf.apps.app_url:
55
# Maybe it is a special app!
56
if req.app == 'logout':
59
# TODO: Nicer 404 message?
60
req.throw_error(Request.HTTP_NOT_FOUND)
62
# Special handling for public mode - just call public app and get out
63
# NOTE: This will not behave correctly if the public app uses
64
# write_html_head_foot, but "serve" does not.
66
app = conf.apps.app_url[conf.apps.public_app]
67
apps.call_app(app.dir, req)
54
# TODO: Nicer 404 message?
55
req.throw_error(Request.HTTP_NOT_FOUND)
70
57
# app is the App object for the chosen app
71
58
if req.app is None:
72
app = conf.apps.app_url[conf.apps.default_app]
59
app = conf.apps.app_url[conf.default_app]
74
61
app = conf.apps.app_url[req.app]
76
63
# Check if app requires auth. If so, perform authentication and login.
77
64
if app.requireauth:
78
req.username = login.login(req)
79
logged_in = req.username is not None
65
# TODO: Perform authentication
68
# If user did not specify an app, HTTP redirect to default app and exit.
70
req.throw_redirect(util.make_path(conf.default_app))
72
# Set the default title to the app's tab name, if any. Otherwise URL name.
73
if app.name is not None:
81
req.username = login.get_username(req)
85
# If user did not specify an app, HTTP redirect to default app and
88
req.throw_redirect(util.make_path(conf.apps.default_app))
90
# Set the default title to the app's tab name, if any. Otherwise URL
92
if app.name is not None:
97
# Call the specified app with the request object
98
apps.call_app(app.dir, req)
99
# if not logged in, login.login will have written the login box.
100
# Just clean up and exit.
78
# Call the specified app with the request object
79
apps.call_app(app.dir, req)
102
81
# MAKE SURE we write the HTTP (and possibly HTML) header. This
103
82
# wouldn't happen if nothing else ever got written, so we have to make
108
87
if req.write_html_head_foot:
109
88
html.write_html_foot(req)
111
# Note: Apache will not write custom HTML error messages here.
112
# Use req.throw_error to do that.
90
# Have Apache output its own HTML code if non-200 status codes were found
116
"""Log out the current user (if any) by destroying the session state.
117
Then redirect to the top-level IVLE page."""
118
session = req.get_session()
121
req.throw_redirect(util.make_path(''))