[Zope] Python Script & file.filename

Milos Prudek milos.prudek@c-box.cz
Wed, 06 Mar 2002 23:04:18 +0100


> Here it looks like you send the value of ad_title to the script as the
> second parameter

Yes. ad_title is HTTPUpload instance. It is NOT a string.

> 
> 
>>Python Script "ad_save" (parameters id,ad,url):
>>
> 
> # Here the parameter called "ad" gets the value of ad_title
> 
>>if ad.filename:
>>
> #It's a string, not an object, so if ad exists, there is no ad.filename

No no, it is not a string. It is HTTP Upload instance. I can prove it:

As long as there is no "ad_title" image file in the current folder, the 
"ad_save" is able to "manage_addImage" succesfully. And if you look at 
manage_addImage parameter you'll see that I'm using file=ad to get to 
image data.

Furthermore, the "if ad.filename" was originally designed to take care 
of situation when the original form did NOT have any filename entered. 
It works very well. If no image was entered on the form, condition 
skips. If there was an image entered, condition is valid.

> A REQUEST variable which is a string, not an object, as best as I can see.

If it were string it would never work. It would never add an image. But 
it refuses to add an image only if there is already an image file 
"ad_title".


-- 
Milos Prudek