summaryrefslogtreecommitdiffstats
path: root/Doc/lib
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2004-06-06 23:28:23 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>2004-06-06 23:28:23 (GMT)
commit44cbfd7819fcc40209d8bcb960eccfa7237b1717 (patch)
tree87c006e68594f51cdd9140061753c6ad863dc19d /Doc/lib
parent9665271f92a5aa7fcd02eda4b6e67f2b23941cb3 (diff)
downloadcpython-44cbfd7819fcc40209d8bcb960eccfa7237b1717.zip
cpython-44cbfd7819fcc40209d8bcb960eccfa7237b1717.tar.gz
cpython-44cbfd7819fcc40209d8bcb960eccfa7237b1717.tar.bz2
[Bug #953177] Mention .getlist(); text from Paul Moore
Diffstat (limited to 'Doc/lib')
-rw-r--r--Doc/lib/libcgi.tex13
1 files changed, 4 insertions, 9 deletions
diff --git a/Doc/lib/libcgi.tex b/Doc/lib/libcgi.tex
index a14717a..3cb07b2 100644
--- a/Doc/lib/libcgi.tex
+++ b/Doc/lib/libcgi.tex
@@ -135,19 +135,14 @@ instance but a list of such instances. Similarly, in this situation,
\samp{form.getvalue(\var{key})} would return a list of strings.
If you expect this possibility
(when your HTML form contains multiple fields with the same name), use
-the \function{isinstance()} built-in function to determine whether you
-have a single instance or a list of instances. For example, this
+the \function{getlist()} function, which always returns a list of values (so that you
+do not need to special-case the single item case). For example, this
code concatenates any number of username fields, separated by
commas:
\begin{verbatim}
-value = form.getvalue("username", "")
-if isinstance(value, list):
- # Multiple username fields specified
- usernames = ",".join(value)
-else:
- # Single or no username field specified
- usernames = value
+value = form.getlist("username")
+usernames = ",".join(value)
\end{verbatim}
If a field represents an uploaded file, accessing the value via the