#1039: TypeError when evaluating FieldStorage object as boolean
------------------------+---------------------------------------------------
 Reporter:  L33tminion  |       Owner:  anonymous
     Type:  defect      |      Status:  new      
 Priority:  normal      |   Milestone:           
Component:  Widgets     |     Version:  0.9a6    
 Severity:  normal      |    Keywords:           
------------------------+---------------------------------------------------
 Problem:  The `cgi.FieldStorage` object (call it `file`) generated by
 `FileField` never has its `list` data member set to something meaningful.
 As a result, trying to evaluate it as a boolean causes a `TypeError` (it
 calls `len(file)` which in turn calls `len(file.keys())`, and
 `file.keys()` throws a `TypeError` because `file.list` is `None`).

 So code of this sort doesn't work:
 {{{
 class MyController(RootController):
     @expose(...)
     def upload(self,file=None,...):
         if file:
             <do stuff with the file...>
 }}}



 Solution:  Make sure `file.list` is set so that the `FieldStorage` object
 evaluates to true unless it's empty.

 Version:  I'm working with Turbogears from SVN trunk, r1629.

-- 
Ticket URL: <http://trac.turbogears.org/turbogears/ticket/1039>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears Tickets" 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/turbogears-tickets
-~----------~----~----~----~------~----~------~--~---

Reply via email to