I've seen numerous postings about this, but so far I have been unsuccessful in successfully subclassing the Image with my own ZClass (called VProduct for this case). Here's what I have managed to do: * Create my new VProduct ZClass with Image as a base class * Add a couple of new simple (string) properties to VProduct * Modify the VProduct_add and VProduct_addForm methods so that my new properties gets asked for and filled in (and using the system clock to generate unique id's) This seem to work great, and I can move about in the Zope filesystem and add instances of my VProduct class as I want to. I have not been able to successfully integrate the file upload feature. What I have done is: * Add an input file <input type=file name=file> in the addForm method * Putting a file name in this field and pressing submit button
From here I am not quite sure what to do with the image, but from browsing earlier postings about this, it seems to have something to do with calling manage_upload one way or the other.
In the VProduct_add method, I have the following special code: <dtml-call "REQUEST.set('ts', ZopeTime ())"> <dtml-call "REQUEST.set('id', _.str(_.int('ts')))"> The above code generates a unique id for my VProduct instances, and this works fine. Inside the automatically generated: <dtml-with "VProduct.createInObjectManager(REQUEST['id'], REQUEST)"> further down in the VProduct_add method I have the following stuff: <dtml-call "propertysheets.Basic.mange_editProperties (REQUEST)"> that code should take care of modifying the properties of my VProduct instance (and assumes I guess that the input field names match the property names). This seams to work great. Right before the "propertysheets..." line I have tried adding the following: <dtml-call "manage_upload(REQUEST['file'])"> It does not generate an error. But it does not seem to manage the upload part either, since my VProduct instance gets the content_type "text/plain" (instead of image/jpeg which is the right type for the jpeg file I try to upload). And when I try to "view" the VProduct instance, I get a simple <img src="91231912" alt="sometext"> tag which displays like a missing image in a web browser (no wonder since the content_type is wrong). I have tried manually setting the content_type to "image/jpeg", but the image still does not display correctly. My guess is that the image never got uploaded. Any ideas on how to handle the upload properly? I've done some 30 searches through the list archive, without any clear answers to how the image uploads are handled (or should be handled). I've looked carefully through the howto's but have not found anything. Any help would be appreciated. Marius Kjeldahl