mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Reworded the doc string to remove the need for The Emacs font-lock kludge.
This required (re)moving all occurrences of '(' in column 0, as well as changing "#!" to #!.
This commit is contained in:
parent
7701fd9af2
commit
4305542517
1 changed files with 13 additions and 15 deletions
28
Lib/cgi.py
28
Lib/cgi.py
|
@ -43,8 +43,8 @@ Here's Python code that prints a simple piece of HTML:
|
||||||
print "<H1>This is my first CGI script</H1>"
|
print "<H1>This is my first CGI script</H1>"
|
||||||
print "Hello, world!"
|
print "Hello, world!"
|
||||||
|
|
||||||
(It may not be fully legal HTML according to the letter of the
|
It may not be fully legal HTML according to the letter of the
|
||||||
standard, but any browser will understand it.)
|
standard, but any browser will understand it.
|
||||||
|
|
||||||
|
|
||||||
Using the cgi module
|
Using the cgi module
|
||||||
|
@ -82,11 +82,11 @@ of FieldStorage (or MiniFieldStorage, depending on the form encoding).
|
||||||
|
|
||||||
If the submitted form data contains more than one field with the same
|
If the submitted form data contains more than one field with the same
|
||||||
name, the object retrieved by form[key] is not a (Mini)FieldStorage
|
name, the object retrieved by form[key] is not a (Mini)FieldStorage
|
||||||
instance but a list of such instances. If you expect this possibility
|
instance but a list of such instances. If you are expecting this
|
||||||
(i.e., when your HTML form comtains multiple fields with the same
|
possibility (i.e., when your HTML form comtains multiple fields with
|
||||||
name), use the type() function to determine whether you have a single
|
the same name), use the type() function to determine whether you have
|
||||||
instance or a list of instances. For example, here's code that
|
a single instance or a list of instances. For example, here's code
|
||||||
concatenates any number of username fields, separated by commas:
|
that concatenates any number of username fields, separated by commas:
|
||||||
|
|
||||||
username = form["username"]
|
username = form["username"]
|
||||||
if type(username) is type([]):
|
if type(username) is type([]):
|
||||||
|
@ -213,16 +213,16 @@ installed; usually this is in a directory cgi-bin in the server tree.
|
||||||
|
|
||||||
Make sure that your script is readable and executable by "others"; the
|
Make sure that your script is readable and executable by "others"; the
|
||||||
Unix file mode should be 755 (use "chmod 755 filename"). Make sure
|
Unix file mode should be 755 (use "chmod 755 filename"). Make sure
|
||||||
that the first line of the script contains "#!" starting in column 1
|
that the first line of the script contains #! starting in column 1
|
||||||
followed by the pathname of the Python interpreter, for instance:
|
followed by the pathname of the Python interpreter, for instance:
|
||||||
|
|
||||||
#! /usr/local/bin/python
|
#! /usr/local/bin/python
|
||||||
|
|
||||||
Make sure the Python interpreter exists and is executable by "others".
|
Make sure the Python interpreter exists and is executable by "others".
|
||||||
|
|
||||||
(Note that it's probably not a good idea to use #! /usr/bin/env python
|
Note that it's probably not a good idea to use #! /usr/bin/env python
|
||||||
here, since the Python interpreter may not be on the default path
|
here, since the Python interpreter may not be on the default path
|
||||||
given to CGI scripts!!!)
|
given to CGI scripts!!!
|
||||||
|
|
||||||
Make sure that any files your script needs to read or write are
|
Make sure that any files your script needs to read or write are
|
||||||
readable or writable, respectively, by "others" -- their mode should
|
readable or writable, respectively, by "others" -- their mode should
|
||||||
|
@ -244,7 +244,7 @@ before importing other modules, e.g.:
|
||||||
sys.path.insert(0, "/usr/home/joe/lib/python")
|
sys.path.insert(0, "/usr/home/joe/lib/python")
|
||||||
sys.path.insert(0, "/usr/local/lib/python")
|
sys.path.insert(0, "/usr/local/lib/python")
|
||||||
|
|
||||||
(This way, the directory inserted last will be searched first!)
|
This way, the directory inserted last will be searched first!
|
||||||
|
|
||||||
Instructions for non-Unix systems will vary; check your HTTP server's
|
Instructions for non-Unix systems will vary; check your HTTP server's
|
||||||
documentation (it will usually have a section on CGI scripts).
|
documentation (it will usually have a section on CGI scripts).
|
||||||
|
@ -298,8 +298,8 @@ your script: replace its main code with the single statement
|
||||||
This should produce the same results as those gotten from installing
|
This should produce the same results as those gotten from installing
|
||||||
the cgi.py file itself.
|
the cgi.py file itself.
|
||||||
|
|
||||||
When an ordinary Python script raises an unhandled exception
|
When an ordinary Python script raises an unhandled exception (e.g.,
|
||||||
(e.g. because of a typo in a module name, a file that can't be opened,
|
because of a typo in a module name, a file that can't be opened,
|
||||||
etc.), the Python interpreter prints a nice traceback and exits.
|
etc.), the Python interpreter prints a nice traceback and exits.
|
||||||
While the Python interpreter will still do this when your CGI script
|
While the Python interpreter will still do this when your CGI script
|
||||||
raises an exception, most likely the traceback will end up in one of
|
raises an exception, most likely the traceback will end up in one of
|
||||||
|
@ -410,8 +410,6 @@ backwards compatible and debugging classes and functions?
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# " <== Emacs font-lock de-bogo-kludgificocity
|
|
||||||
|
|
||||||
__version__ = "2.2"
|
__version__ = "2.2"
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue