[Zope] Making ZClasses Inherit Subobjects from Bases

Ross Patterson rossp@ppc.ucsc.edu
Fri, 8 Feb 2002 14:16:45 -0800 (PST)


If I create a ZClass, ZC1, that subclasses ZClasses: ObjectManager and
then create another, ZC2, that subclasses ZC1.  As long as I don't
save changes in the subobjects tab of ZC2, it will inherit the
subobjects settings from ZC1.  But as soon as I do save any changes,
there is then no way to unset the subobjects and return it to the
inherited subobjects.

I think the way to do this would be to write a python method of my
python base ZClass that calls the delClassAttr method from
ZClasses.ZClass.  But I can't seem to get this to work.  Below are my
python files:


#!/usr/bin/python
# Products/ZCapitalProjects/ZCPBases.py

from ZClasses.ObjectManager import ObjectManager, ZObjectManagerPropertySheets
from Products.ZCatalog.CatalogPathAwareness import CatalogAware
from OFS.PropertyManager import PropertyManager

class ZClassBases ( CatalogAware, ObjectManager, PropertyManager ) :
	"""
	Base Classes for all ZCP ZClasses
	"""

	pass

class ZCPBases :
    """Mix-in for Bases
    """

    _zclass_=ZClassBases

    propertysheets=ZObjectManagerPropertySheets()

    manage_options=(
        {'label': 'Subobjects', 'action' :'propertysheets/subobjects/manage'},
        )

    def inheritSubobjects( self ) :
	"""
	Delete the meta_types attribute in _zclass so that the class will inherit
	"""

	self.delClassAttr( self, 'meta_types' )


#!/usr/bin/python
# Products/ZCapitalProjects/__init__.py

from ZClasses import createZClassForBase

from ZCPBases import ZCPBases
from PartBase import PartBase
from Part import Part
from SitePart import SitePart
from ProjectPart import ProjectPart
from Site import Site
from Project import Project
from ProjectsContainer import ProjectsContainer

createZClassForBase( PartBase, globals(), 'ZCPPartBase' )
createZClassForBase( Part, globals(), 'ZCPPart' )
createZClassForBase( SitePart, globals(), 'ZCPSitePart' )
createZClassForBase( ProjectPart, globals(), 'ZCPProjectPart' )
createZClassForBase( Site, globals(), 'ZCPSite' )
createZClassForBase( Project, globals(), 'ZCPProject' )
createZClassForBase( ProjectsContainer, globals(), 'ZCPProjectsContainer' )

def initialize( context ) :

	context.registerZClass( ZCPBases )

-----------------------------------------------------------------
| Ross Patterson			rossp@cats.ucsc.edu	|
| Programmer/Analyst			(831)459-2792		|
| Physical Planning & Construction	Fax:(831)423-7436	|
| UC Santa Cruz				http:www2.ucsc.edu/ppc	|
-----------------------------------------------------------------