[Zope] Q: How to check if Image exists (inside REQUEST object)?

Samu Mielonen ex@uiah.fi
Mon, 25 Oct 1999 10:13:05 +0300


I have another (for me) tought nut to crack and would appreciate
any help:

I'm handling a submit-form (now in multi-part/formdata :) with a
method called postit (from KMNetNews). I'm trying to detect within
postit whether an image was included in the image1 property of
the submit form (i.e. did the user decide to upload an image with
the <input type=file name=image1> button):

I.e. my hierarchy:

	../../uniqueID		- folderish article object
		edit			- the submit form
		postit		- the method that receives submit form data

Inside postit I check:

	<dtml-if "image1">

The above always returns true, regardless of whether I've submitted
an image via the edit-form or not. Same for:

	<dtml-if image1>

	<dtml-if "REQUEST.image1">

	<dtml-if "_.str(REQUEST.image1)">

	<dtml-if "_.str(REQUEST['image1'])">

	<dtml-if "not _.str(image1)==''">

they always return TRUE regardless of whether I submitted an image
via the submit's form image1 property. Furthermore:

	*<dtml-var image1>*

returns:

	**

i.e. a null/empty/none contents!

I tried to get the get_size, size and getSize methods to work with
the image object*, but I always got an AttributeError, so I couldn't
do the checking via size either.

	* as a matter of fact, I'm not sure image1 is
	  an image object, if no image was included in the submit form?

I also tried forcing the image1-property to an actual data type
through HTML, in case no image was specified for uploading:

	<input type=file name="image1:boolean" value="off">

... and tried to check with that too, but that didn't help either.
I always get TRUE, whatever I do.

So, how can I check whether an image was submitted or not?
I'm beginning to sucpect I've misunderstood something gravely.


Best regards,
	Samu Mielonen

PS Once again I scoured the mailing list archives, but found no
references to this problem. My apologies, if this is a trivial
question or a faq.

--
"Our reflections on the order of society, as well as nature, are still
dominated by the Newtonian image of massive power, exerted by sovereign
agency through the operation of central force..." -Stephen Toulmin,
"Cosmopolis"