52
53
# Check req.app to see if it is valid. 404 if not.
53
54
if req.app is not None and req.app not in conf.apps.app_url:
54
# TODO: Nicer 404 message?
55
req.throw_error(Request.HTTP_NOT_FOUND)
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)
57
70
# app is the App object for the chosen app
58
71
if req.app is None:
59
app = conf.apps.app_url[conf.default_app]
72
app = conf.apps.app_url[conf.apps.default_app]
61
74
app = conf.apps.app_url[req.app]
63
76
# Check if app requires auth. If so, perform authentication and login.
64
77
if app.requireauth:
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:
78
req.username = login.login(req)
79
logged_in = req.username is not None
78
# Call the specified app with the request object
79
apps.call_app(app.dir, req)
81
req.username = login.get_username(req)
85
# Keep the user's session alive by writing to the session object.
86
req.get_session().save()
87
# If user did not specify an app, HTTP redirect to default app and
90
req.throw_redirect(util.make_path(conf.apps.default_app))
92
# Set the default title to the app's tab name, if any. Otherwise URL
94
if app.name is not None:
99
# Call the specified app with the request object
100
apps.call_app(app.dir, req)
101
# if not logged in, login.login will have written the login box.
102
# Just clean up and exit.
81
104
# MAKE SURE we write the HTTP (and possibly HTML) header. This
82
105
# wouldn't happen if nothing else ever got written, so we have to make
87
110
if req.write_html_head_foot:
88
111
html.write_html_foot(req)
90
# Have Apache output its own HTML code if non-200 status codes were found
113
# Note: Apache will not write custom HTML error messages here.
114
# Use req.throw_error to do that.
118
"""Log out the current user (if any) by destroying the session state.
119
Then redirect to the top-level IVLE page."""
120
session = req.get_session()
123
req.throw_redirect(util.make_path(''))