Mike Looijmans
nlv11281 at natlab.research.philips.com
Tue Feb 21 01:48:46 EST 2006
I saw that traceback too, but it is util.py that is going wrong here: ## code snippet from mod_python/util.py def __getitem__(self, key): """Dictionary style indexing.""" if self.list is None: raise TypeError, "not indexable" found = [] for item in self.list: if item.name == key: if isinstance(item.file, FileType) or \ isinstance(getattr(item.file, 'file', None), FileType): found.append(item) else: found.append(StringField(item.value)) if not found: raise KeyError, key if len(found) == 1: return found[0] else: return found ## end code snippet from mod_python/util.py The result is that the callback will ONLY work if you create a REAL file in make_file. Otherwise, the "isinstance(item.file, FileType)" will return FALSE and it creates a StringField, which attempts to read the whole file into memory (not a good idea). Then you get the stacktrace. It also means that you won't get the filename back from the form. I have submitted a patch that fixes the issue, but it is scheduled for 3.3 now. -- Mike Looijmans Philips Natlab / Topic Automation Daniel Nogradi wrote: >>Hmm. I tested and indeed, the program does not work any more. >> >>The problem is NOT that FileCounter does not supply a read() method though. >>There's no reason for >>any object to 'read' the file, it's just writing it. > > > Well, here is the traceback that I get: > > Mod_python error: "PythonHandler mod_python.psp" > > Traceback (most recent call last): > > File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line > 299, in HandlerDispatch > result = object(req) > > File "/usr/lib/python2.3/site-packages/mod_python/psp.py", line 302, > in handler > p.run() > > File "/usr/lib/python2.3/site-packages/mod_python/psp.py", line 213, in run > exec code in global_scope > > File "/var/www/html/psp/upload.psp", line 43, in ? > for afile in frm.getlist('archivefile'): > > File "/usr/lib/python2.3/site-packages/mod_python/util.py", line > 354, in getlist > found.append(StringField(item.value)) > > File "/usr/lib/python2.3/site-packages/mod_python/util.py", line 74, > in __getattr__ > value = self.file.read() > > AttributeError: FileCounter instance has no attribute 'read' > > > That seems pretty clear about a required 'read' method in util.py. > > > >>(Oh, and remove the reference to 'fmt.py' which I forgot to strip out) > > > Yes of course, I removed that. > > _______________________________________________ > Mod_python mailing list > Mod_python at modpython.org > http://mailman.modpython.org/mailman/listinfo/mod_python
|