cgi, classes and their instances
Denis S. Otkidach
ods at strana.ru
Tue Jul 13 04:47:18 EDT 2004
On Tue, 13 Jul 2004, Klaus Neuner wrote:
KN> code (1) works, code (2) doesn't.
Are you using POST method? In this case data come from stdin,
which can be read only once, so the second call to constructor
recieves nothing.
KN> (1)
KN> data = cgi.FieldStorage()
KN> comment = data.getvalue("comment")
KN> user_name = data.getvalue("user_name")
KN>
KN> (2)
KN> data = cgi.FieldStorage()
KN> comment = cgi.FieldStorage().getvalue("comment")
KN> user_name = cgi.FieldStorage().getvalue("user_name")
BTW, I'd suggest using getfirst/getlist methods of FieldStorage,
since their behavior is the same independent on form content.
Thus you need less code to check.
--
Denis S. Otkidach
http://www.python.ru/ [ru]
More information about the Python-list
mailing list