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
# Keep the user's session alive by writing to the session object.
86
# req.get_session().save()
87
# Well, it's a fine idea, but it creates considerable grief in the
88
# concurrent update department, so instead, we'll just make the
89
# sessions not time out.
91
# If user did not specify an app, HTTP redirect to default app and
94
req.throw_redirect(util.make_path(conf.apps.default_app))
96
# Set the default title to the app's tab name, if any. Otherwise URL
98
if app.name is not None:
103
# Call the specified app with the request object
104
apps.call_app(app.dir, req)
105
# if not logged in, login.login will have written the login box.
106
# Just clean up and exit.
78
# Call the specified app with the request object
79
apps.call_app(app.dir, req)
108
81
# MAKE SURE we write the HTTP (and possibly HTML) header. This
109
82
# wouldn't happen if nothing else ever got written, so we have to make
114
87
if req.write_html_head_foot:
115
88
html.write_html_foot(req)
117
# Note: Apache will not write custom HTML error messages here.
118
# Use req.throw_error to do that.
90
# Have Apache output its own HTML code if non-200 status codes were found
122
"""Log out the current user (if any) by destroying the session state.
123
Then redirect to the top-level IVLE page."""
124
session = req.get_session()
127
req.add_cookie(forumutil.invalidated_forum_cookie())
128
req.throw_redirect(util.make_path(''))