[Zope] Subclassing Confusion

James W. Howe jwh@allencreek.com
Wed, 19 Jan 2000 13:20:22 -0500


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 subclassed Image as follows (using the Renderable product as 
an example):

import Acquisition
from OFS import Image

class RenderableImage:
     def __str__ (self):
	Request = self.REQUEST
	if Request:
	    try:
		Method = getattr (self, 'render')
	    except AttributeError:
		return Image.__str__(self)
	    return Method (self, Request)
	else:
	    return "Renderable error: no request"

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.

Thanks.

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