[Zope] Subclassing Confusion

James W. Howe jwh@allencreek.com
Wed, 19 Jan 2000 14:31:53 -0500


At 01:20 PM 1/19/00 -0500, you wrote:
>I just tried to create a Python Base class for the purpose of overriding 
>Images __str__ method and things didn't quite work as I would have expected.
>[...]
>I defined a __init__ method to make the class a base class.  I then went 
>into my Product and create a new ZClass which used RenderableImage as a 
>base class.  Since I was just testing things, I immediately went and tried 
>to create a new instance.  No problem creating the object.  The problem 
>(or my confusion) was the fact that my RenderableImage didn't inherit any 
>of the views which an Image would normally have (i.e. Edit, Upload, 
>Properties, View, Security).  My question is why didn't they show up?  I 
>would have thought that absent any other changes to my Image subclass, 
>that the default Image views would show up as the views of my new ZClass.

I figured it out.  It would help to actually subclass from Image.  Instead of

class RenderableImage:

I need to use something like:

class RenderableImage(Image):

I've done this and things almost work they way I want.  The only problem I 
have now is that when I select a base class for my ZClass, I see two 
"Image" entries.    I currently have the following in my __init__.py file:

from RenderableImage import RenderableImage

def initialize (context):
     context.registerBaseClass (RenderableImage)

What do I need to do to have the name "RenderableImage" in my base class 
list instead of two "Image" entries?

Thanks.


James W. Howe				mailto:jwh@allencreek.com
Allen Creek Software, Inc.		pgpkey: http://ic.net/~jwh/pgpkey.html		
Ann Arbor, MI  48103