sanjeev c s writes:
i have a form which uploads a file. and it calls a method which pass parameter to a python script. this python script creates a 'file object'. .... if picture: container.foldername.manage_addImage(id=id, file=picture)
but still even if the file is not uploaded the 'file object' is created. what is the problem ?? The reason is easy:
Even if no file is uploaded, you get a "FileUpload" object. Unfortunately, the "FileUpload" class does not define senseful "__len__" or "__nonzero__" methods (this is a bug --> <http:collector.zope.org>) and therefore, all such objects are considered Python true values. Your options: * Fix "ZPublisher.HTTPRequest.FileUpload" such that it defines a "__nonzero__" method. Post your patch to the collector (see above). This way, you help improve Zope * Work around the problem in your application code. You can use: "if picture.filename:" in place of "if picture:" Dieter