[Zope] Python based ZClass Questions

James W. Howe jwh@allencreek.com
Thu, 03 Feb 2000 08:59:01 -0500


I've been playing around with ZClasses.  I've created thin Python classes 
to use as a base class for my ZClass.  I have a couple of questions 
regarding the best way to make use of this base class, however.

First, if I create a Python base class, should I use it to control the the 
collection of base classes used by my ZClass?  For example, suppose that I 
originally create a ZClass which has a base of MyPythonBase.  Suppose that 
MyPythonBase does not inherit from something like ObjectManager.  Later I 
decide that my ZClass needs to have ObjectManager behavior.  Can I modify 
my base class to now inherit from ObjectManager?

Second, if I define my base class inheritance from the ZClass definition 
interface, when I define new ZClasses which inherit from my Python base 
class, should I put my base class first in the list of base classes or 
last?  If I understand how inheritance works, attributes are searched depth 
first, left to right.  I believe this means that if I wanted to override 
some behavior of one of the other inherited classes, I would have to have 
my class first.  What are the pros and cons of having my base class first 
or last?

Finally, I've noticed that when a ZClass is defined, a predefined set of 
"views" are created for the object.  For example, the "Contents" view might 
have "manage_main" and something else defined as available view 
methods.  If methods are added to the ZClass, they show up in the list.  If 
I wanted to define some new methods at the Python level, what do I need to 
do to have them show up in the view list?  For example, suppose that I 
create a subclass of Folder and I want to have an alternative way to view 
the my folders contents.  I can think of two ways to make this 
work.  First, make sure that my base class is first in the inheritance list 
and then override the definition of something like "manage_main", 
substituting my DTML code for the standard DTML code.  Alternatively, I 
could define a new method in my ZClass which has the DTML code I 
desire.  What I'd like to know is how I could define a new method in my 
Python code and have it selectable as an available view.

Thanks.

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