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, "Available Applications", conf.apps.app_url.items())
50
print_table(req, "Request Properties", [
56
# Violate encapsulation here to print out the hidden properties
57
print_table(req, "Apache (Hidden) Request Properties", [
58
("hostname", req.apache_req.hostname),
59
("method", req.apache_req.method),
60
("unparsed_uri", req.apache_req.unparsed_uri),
61
("parsed_uri", req.apache_req.parsed_uri),
62
("uri", req.apache_req.uri),
63
("filename", req.apache_req.filename),
64
("path_info", req.apache_req.path_info),
67
print_table(req, "HTTP Request Headers",
68
req.apache_req.headers_in.items())
69
req.apache_req.add_common_vars()
70
print_table(req, "CGI Environment Variables",
71
req.apache_req.subprocess_env.items())
72
print_table(req, "Server Environment Variables", os.environ.items())
74
req.write("<h3>Removal instructions</h3>\n")
75
req.write("""<p>In a production environment, debuginfo should be disabled.
76
To do this, comment out or remove the debuginfo line of the app_url
77
dictionary in conf/apps.py.</p>
78
<p>For extra security, it may be removed completely by deleting the
79
apps/debuginfo directory.</p>\n""")
81
def print_table(req, tablename, mapping):
82
"""Prints an HTML table with a heading.
84
mapping: An associative list (a list of pairs). The pairs are printed
85
using (str, repr) respectively into the two-column table."""
86
req.write("<h3>%s</h3>\n" % tablename)
87
req.write('<table border="1">\n')
89
req.write("<tr><th>%s</th><td>%s</td></tr>\n" % (str(k), repr(v)))
90
req.write("</table>\n")