81
80
in the head, if write_html_head_foot is True.
82
81
URLs should be relative to the IVLE root; they will be fixed up
83
82
to be site-relative.
85
List of strings. Write a list of JS function names, and they
86
will be added as window.addListener('load', ..., false); calls
87
in the head, if write_html_head_foot is True.
88
This is the propper way to specify functions that need to run at
90
83
write_html_head_foot (write)
91
84
Boolean. If True, dispatch assumes that this is an XHTML page, and
92
85
will immediately write a full HTML head, open the body element,
210
202
"""Writes out the HTTP and HTML headers before any real data is
212
204
self.headers_written = True
214
# app is the App object for the chosen app
216
app = conf.apps.app_url[self.app]
220
# Write any final modifications to header content
221
if app and app.useconsole and self.user:
222
plugins.console.insert_scripts_styles(self.scripts, self.styles, \
225
205
# Prepare the HTTP and HTML headers before the first write is made
226
206
if self.content_type != None:
227
207
self.apache_req.content_type = self.content_type
272
252
return self.apache_req.read(len)
274
def throw_error(self, httpcode, message=None):
254
def throw_error(self, httpcode):
275
255
"""Writes out an HTTP error of the specified code. Raises an exception
276
256
which is caught by the dispatch or web server, so any code following
277
257
this call will not be executed.
279
259
httpcode: An HTTP response status code. Pass a constant from the
282
raise common.util.IVLEError(httpcode, message)
262
raise mod_python.apache.SERVER_RETURN, httpcode
284
264
def throw_redirect(self, location):
285
265
"""Writes out an HTTP redirect to the specified URL. Raises an
325
305
self.apache_req.add_common_vars()
326
306
self.got_common_vars = True
327
307
return self.apache_req.subprocess_env
330
def get_http_codename(code):
331
"""Given a HTTP error code int, returns a (name, description)
332
pair, suitable for displaying to the user.
333
May return (None,None) if code is unknown.
334
Only lists common 4xx and 5xx codes (since this is just used
335
to display throw_error error messages).
338
return http_codenames[code]
342
# Human strings for HTTP response codes
344
Request.HTTP_BAD_REQUEST:
346
"Your browser sent a request IVLE did not understand."),
347
Request.HTTP_UNAUTHORIZED:
349
"You are not allowed to view this part of IVLE."),
350
Request.HTTP_FORBIDDEN:
352
"You are not allowed to view this part of IVLE."),
353
Request.HTTP_NOT_FOUND:
355
"The application or file you requested does not exist."),
356
Request.HTTP_METHOD_NOT_ALLOWED:
357
("Method Not Allowed",
358
"Your browser is interacting with IVLE in the wrong way."
359
"This is probably a bug in IVLE. "
360
"Please report it to the administrators."),
361
Request.HTTP_INTERNAL_SERVER_ERROR:
362
("Internal Server Error",
363
"An unknown error occured in IVLE."),
364
Request.HTTP_NOT_IMPLEMENTED:
366
"The application or file you requested has not been implemented "
368
Request.HTTP_SERVICE_UNAVAILABLE:
369
("Service Unavailable",
370
"IVLE is currently experiencing technical difficulties. "
371
"Please try again later."),