Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
44cbfd78
Commit
44cbfd78
authored
Jun 06, 2004
by
Andrew M. Kuchling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Bug #953177] Mention .getlist(); text from Paul Moore
parent
9665271f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
9 deletions
+4
-9
Doc/lib/libcgi.tex
Doc/lib/libcgi.tex
+4
-9
No files found.
Doc/lib/libcgi.tex
View file @
44cbfd78
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment