There is still trouble with the FieldStorage class. Looks like this one is not 
really fixed:
http://issues.apache.org/jira/browse/MODPYTHON-40

See for a counter example:
http://modpython.org/pipermail/mod_python/2006-February/020248.html
(remove the "import fmt")
It fails with the following traceback:

Mod_python error: "PythonHandler mod_python.psp"

Traceback (most recent call last):

  File "C:\Python24\Lib\site-packages\mod_python\apache.py", line 299, in 
HandlerDispatch
    result = object(req)

  File "C:\Python24\Lib\site-packages\mod_python\psp.py", line 302, in handler
    p.run()

  File "C:\Python24\Lib\site-packages\mod_python\psp.py", line 213, in run
    exec code in global_scope

  File "C:/source/archaic_web/upload.psp", line 47, in ?
    for afile in frm.getlist('archivefile'):

  File "C:\Python24\Lib\site-packages\mod_python\util.py", line 354, in getlist
    found.append(StringField(item.value))

  File "C:\Python24\Lib\site-packages\mod_python\util.py", line 74, in 
__getattr__
    value = self.file.read()

AttributeError: FileCounter instance has no attribute 'read'


The file is posted as file, and correctly writting into the FileCounter. However, the FieldStorage class forgets about this, and in util.py it tries to determine whether this is a file or not by looking whether it derives from FileType. Since any "home made" file object is not likely to derive from that class, util.py concludes that this was a simple field, and does a file.read() to fetch it into memory (which is what we were preventing in issue 40)

A quick way to solve it is to use this code:
http://issues.apache.org/jira/browse/MODPYTHON-93
this will remove the bad checks for field types alltogether.

--
Mike Looijmans
Philips Natlab / Topic Automation

Reply via email to