Issue1015249
Created on 2004-08-24 13:32 by yxcv, last changed 2009-04-22 15:22 by ajaksu2.
|
msg60552 - (view) |
Author: Andreas Ames (yxcv) |
Date: 2004-08-24 13:32 |
|
This makes it hazardous to do the following:
fs = cgi.FieldStorage(...)
if fs:
...
Suggestions:
1) Fix __len__; sorry, but I don't know how.
2) Create FieldStorage.__nonzero__; a hack.
3) ?
|
|
msg60553 - (view) |
Author: Johannes Gijsbers (jlgijsbers) |
Date: 2004-08-30 14:47 |
|
Logged In: YES
user_id=469548
As far as I can tell, cgi.FieldStorage.__len__ only raises a
TypeError if the FieldStorage is not indexable. It's
reasonable not to support len() on an unindexable FieldStorage.
I'm just wondering why you would want to do:
fs = cgi.FieldStorage(...)
if fs:
...
Defining __nonzero__ seems reasonable if there's a reason
for testing a FieldStorage for truth value.
|
|
msg60554 - (view) |
Author: Andreas Ames (yxcv) |
Date: 2004-09-02 12:26 |
|
Logged In: YES
user_id=898176
For a code snippet please look at:
http://mail.python.org/pipermail/python-list/2004-August/235988.html
AFAIK, cgi.FieldStorage is meant to either (sort of) 'be' a
list or a
file after having parsed the request. So one could possibly
take the
builtin file object as kind of evidence:
>>> f = file('/etc/passwd')
>>> len(f)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: len() of unsized object
>>> if f:
... print 'yes'
... else:
... print 'no'
...
yes
>>>
|
|
| Date |
User |
Action |
Args |
| 2009-04-22 15:22:08 | ajaksu2 | set | keywords:
+ easy |
| 2009-02-14 14:43:41 | ajaksu2 | set | stage: test needed type: behavior versions:
+ Python 2.6, - Python 2.3 |
| 2004-08-24 13:32:25 | yxcv | create | |
|