2
# Copyright (C) 2007-2008 The University of Melbourne
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
# Displays lots of internal information about IVLE's running environment,
24
# Important: This application should be removed from a production system.
26
from common import util
32
"""Handler for the Debug Information application."""
34
# Set request attributes
35
req.content_type = "text/html"
36
req.write_html_head_foot = True # Have dispatch print head and foot
39
req.write("<h2>IVLE Debug Information</h2>\n")
41
print_table(req, "System Constants", [
42
("ivlepath", conf.ivlepath),
43
("root_dir", conf.root_dir),
44
("student_dir", conf.student_dir),
45
("default_app", conf.default_app),
48
print_table(req, "Request Properties", [
54
print_table(req, "Available Applications", conf.apps.app_url.items())
56
print_table(req, "Environment Variables", os.environ.items())
58
req.write("<h3>Removal instructions</h3>\n")
59
req.write("""<p>In a production environment, debuginfo should be disabled.
60
To do this, comment out or remove the debuginfo line of the app_url
61
dictionary in conf/apps.py.</p>
62
<p>For extra security, it may be removed completely by deleting the
63
apps/debuginfo directory.</p>\n""")
65
def print_table(req, tablename, mapping):
66
"""Prints an HTML table with a heading.
68
mapping: An associative list (a list of pairs). The pairs are printed
69
using (str, repr) respectively into the two-column table."""
70
req.write("<h3>%s</h3>\n" % tablename)
71
req.write('<table border="1">\n')
73
req.write("<tr><th>%s</th><td>%s</td></tr>\n" % (str(k), repr(v)))
74
req.write("</table>\n")