"
traceback.print_exc()
-Notes: The assignment to sys.stderr is needed because the traceback prints
-to sys.stderr. The print "\n\n" statement is necessary to disable the
-word wrapping in HTML.
+Notes: The assignment to sys.stderr is needed because the traceback
+prints to sys.stderr. The print "\n\n" statement is necessary to
+disable the word wrapping in HTML.
-If you suspect that there may be a problem in importing the traceback
-module, you can use an even more robust approach (which only uses built-in
-modules):
+If you suspect that there may be a problem in importing the traceback
+module, you can use an even more robust approach (which only uses
+built-in modules):
import sys
sys.stderr = sys.stdout
@@ -272,12 +282,13 @@ modules):
print
...your code here...
-This relies on the Python interpreter to print the traceback. The content
-type of the output is set to plain text, which disables all HTML
-processing. If your script works, the raw HTML will be displayed by your
-client. If it raises an exception, most likely after the first two lines
-have been printed, a traceback will be displayed. Because no HTML
-interpretation is going on, the traceback will readable.
+This relies on the Python interpreter to print the traceback. The
+content type of the output is set to plain text, which disables all
+HTML processing. If your script works, the raw HTML will be displayed
+by your client. If it raises an exception, most likely after the
+first two lines have been printed, a traceback will be displayed.
+Because no HTML interpretation is going on, the traceback will
+readable.
Good luck!
@@ -285,40 +296,40 @@ Good luck!
Common problems and solutions
-----------------------------
-- Most HTTP servers buffer the output from CGI scripts until the script is
-completed. This means that it is not possible to display a progress report
-on the client's display while the script is running.
+- Most HTTP servers buffer the output from CGI scripts until the
+script is completed. This means that it is not possible to display a
+progress report on the client's display while the script is running.
- Check the installation instructions above.
-- Check the HTTP server's log files. ("tail -f logfile" in a separate
+- Check the HTTP server's log files. ("tail -f logfile" in a separate
window may be useful!)
-- Always check a script for syntax errors first, by doing something like
-"python script.py".
+- Always check a script for syntax errors first, by doing something
+like "python script.py".
- When using any of the debugging techniques, don't forget to add
"import sys" to the top of the script.
-- When invoking external programs, make sure they can be found. Usually,
-this means using absolute path names -- $PATH is usually not set to a
-very useful value in a CGI script.
+- When invoking external programs, make sure they can be found.
+Usually, this means using absolute path names -- $PATH is usually not
+set to a very useful value in a CGI script.
-- When reading or writing external files, make sure they can be read or
-written by every user on the system.
+- When reading or writing external files, make sure they can be read
+or written by every user on the system.
-- Don't try to give a CGI script a set-uid mode. This doesn't work on most
-systems, and is a security liability as well.
+- Don't try to give a CGI script a set-uid mode. This doesn't work on
+most systems, and is a security liability as well.
History
-------
-Michael McLay started this module. Steve Majewski changed the interface to
-SvFormContentDict and FormContentDict. The multipart parsing was inspired
-by code submitted by Andreas Paepcke. Guido van Rossum rewrote,
-reformatted and documented the module and is currently responsible for its
-maintenance.
+Michael McLay started this module. Steve Majewski changed the
+interface to SvFormContentDict and FormContentDict. The multipart
+parsing was inspired by code submitted by Andreas Paepcke. Guido van
+Rossum rewrote, reformatted and documented the module and is currently
+responsible for its maintenance.
"""
@@ -376,7 +387,7 @@ def parse_qs(qs):
if len(nv) != 2:
continue
name = nv[0]
- value = urllib.unquote(regsub.gsub('+',' ',nv[1]))
+ value = urllib.unquote(regsub.gsub('+', ' ', nv[1]))
if len(value):
if dict.has_key (name):
dict[name].append(value)
@@ -528,13 +539,13 @@ class FormContentDict:
class SvFormContentDict(FormContentDict):
"""Strict single-value expecting form content as dictionary.
- IF you only expect a single value for each field, then form[key]
- will return that single value.
- It will raise an IndexError if that expectation is not true.
- IF you expect a field to have possible multiple values, than you
- can use form.getlist(key) to get all of the values.
- values() and items() are a compromise: they return single strings
- where there is a single value, and lists of strings otherwise.
+ IF you only expect a single value for each field, then
+ form[key] will return that single value. It will raise an
+ IndexError if that expectation is not true. IF you expect a
+ field to have possible multiple values, than you can use
+ form.getlist(key) to get all of the values. values() and
+ items() are a compromise: they return single strings where
+ there is a single value, and lists of strings otherwise.
"""
def __getitem__(self, key):
@@ -627,7 +638,7 @@ def test():
print_environ()
print_form(FormContentDict())
print
- print "Current Working Directory
"
+ print "Current Working Directory:
"
try:
pwd = os.getcwd()
except os.error, msg: