[Zope] Change a ZClass's instance's image
Kam Cheung
zope@littlecircle.com
Tue, 05 Oct 1999 13:17:08 +0000
I created a ZClass, let's call it "TestZClass". It's a very simple ZClass --
it has an image and an index_html method.
TestZClass
TestImage
index_html
In the TestZClass_add constructor, I put in a code fragment like this:
<dtml-with "TestZClass.createInObjectManager(REQUEST['id'], REQUEST)">
<dtml-call "TestImage.manage_upload(REQUEST['uploadImage'])">
</dtml-with>
In the TestZClass_addForm HTML, I have:
<form action="TestZClass_add" METHOD="post" ENCTYPE="multipart/form-data">
<table>
<tr>
<th>Id:</th>
<td><INPUT TYPE="text" NAME="id" SIZE="40"></td>
</tr>
<tr>
<th>Image:</th>
<td><INPUT TYPE="file" NAME="uploadImage" SIZE="25"></td>
</tr>
<tr>
<td></td>
<td><INPUT TYPE="submit" VALUE=" Add "></td>
</tr>
</table>
</form>
What I want to do is, when the addForm HTML is called, one can upload an
image and create an instance of TestZClass that overides the default
TestImage in the original Class.
It does override the original TestImage, but if one make another instance of
TestZClass, the TestImage of all the other instances will be changed to the
latest uploaded image.
For example, if I create an instance of TestZClass, call it Instance1 and
upload an image Image1. Instance1' TestImage will become Image1. However, if
I create another instance of TestZClass, let's call it Instance2 and upload
Image2, then not only Instance2's TestImage will become Image2, but
Instance1's TestImage will also be changed to Image2!!!
When I go back to check the TestZClass, it's very clear to me that, the
TestZClass constructor change the TestImage on the ZClass, not on the
instance.
Anyone know how I can force it to change the TestImage in the instance, not
the ZClass?
Kam