On Fri, Jun 27, 2008 at 11:52 AM, Jonathan Vanasco <[EMAIL PROTECTED]> wrote: > > I'm trying to do something akin to the 'quick' way in the cookbook > ( though not for a large file ) > > photofile = request.POST['userphoto'] > > the problem is that i learned that I can not do this: > > if not photofile: > > to make sure that someone submitted a photo. > > that raises an error: > > File '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ > cgi.py', line 633 in __len__ > return len(self.keys()) > File '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ > cgi.py', line 609 in keys > raise TypeError, "not indexable" > TypeError: not indexable
I got that same problem. it's a bug in the upload object used by cgi.FieldStorage. You can't test it for truth or booleanize it. Instead you can compare it to None: if self.form_result["myfile"] is not None: Or you can check if it has an attribute like 'filename', which an actual upload would. -- Mike Orr <[EMAIL PROTECTED]> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~----------~----~----~----~------~----~------~--~---
