[Zope-dev] Z Classes and contained objects
Michel Pelletier
michel@digicool.com
Fri, 30 Jul 1999 22:41:02 -0400
Josh Zeidner wrote:
>
> Currently, I am working with ZClasses with a "contained" image object. In
> other words, I created an Image object in the "method" screen. I also
> created an "image" upload view that performs one simple function, uploads an
> image.
>
By putting a Zope image object in the ZClass definition, you are
defining a class attribute, NOT an instance attribute. Changing this
object will change the attribute for all instances.
To instanciate a new image object in your instances, add DTML like:
<!--#call manage_addImage(id_of_image, image_file)-->
in the ZClass constructor (which is usualy a peer object of the ZClass,
not subordinate). Note that if you add your ZClasses programaticly
(from an external method) and you don't call the constructor, you will
need to simulate what the constructor does. This is an uncommon need,
however.
> The problem may lie in the way I am uploading this image. Here is the
> line of code that I got from a Zope Doc :
>
> medium_pic.manage_upload(REQUEST['new_pic'])
>
> The symptoms of this bug are either inconsistently broken images when
> viewing the object or distorted images( the image is not retaining its
> aspect ratio ).
>
Hmmm.. This might be because several threads are trying to access the
same class attribute at once. But I don't really know.
-Michel