Eric Larson wrote:
> I'm trying to do a simple file upload with webob:
> 
> def upload(self, environ, start_response):
>     req = Request(environ)
>     if req.POST.get('upload'):
>          save_file(req.POST['upload']
>     res = HTTPSeeOther('/other')
> 
> I get not indexable error. I can wrap things in a try/except block but
> I'm wondering if I'm just missing a technique. It is somewhat clear
> the error occurs b/c of a len() check in the FieldStorage, but I'd
> like to verify it is an actual file as well.

If you want to check it is a file, getattr(req.POST['upload'], 
'filename', None) is probably the best way.  Using 
req.POST['upload'].value to get the body is probably best.


-- 
Ian Bicking : [EMAIL PROTECTED] : http://blog.ianbicking.org

_______________________________________________
Paste-users mailing list
[email protected]
http://webwareforpython.org/cgi-bin/mailman/listinfo/paste-users

Reply via email to