[Zope-CMF] ZClass content type question...
sean.upton@uniontrib.com
sean.upton@uniontrib.com
Sat, 31 Aug 2002 15:29:25 -0700
Perhaps this is the wrong list for this question... I am currently using
ZClasses to extend some Python products I have written for use as CMF
content types. I am subclassing my content class (which provides its own
DublinCore and other metadata implementations) and also PortalContent. My
concern is the places where there are method name/implementation overlaps
between these two superclasses.
Normally, outside of using a ZClass, I would just override the method, and
call the method in the appropriate superclass. I thought I might be able to
do this by using an external method inside my ZClass, but I'm not sure of
the best way to get a reference to the superclasses. I've tried:
myClass = self.__class__
bases = myClass.__bases__
...which will get something like this:
(<extension class ZClasses.ZClass.PersistentClass at 851a680>, <extension
class Products.ZXPContent.NITFCoreImpl.NITFCoreImpl at 8c32c28>, <extension
class Products.CMFCore.PortalContent.PortalContent at 8683dd0>, <extension
class OFS.SimpleItem.SimpleItem at 8471170>)
If I have my external method do something like this, I assume I can do this:
import string
def Date(self):
myClass = self.__class__
bases = myClass.__bases__
for base in bases:
if string.find(base.__name__, 'NITFCoreImpl') != -1:
useThisBase = base
break
return useThisBase.Date(self)
I assume that I can do this wherever I need to, but is this the best
approach to doing this, or is there something more simple that I'm not aware
of - or simply not seeing?
Sean
+-----------------------------------------------------------
| Sean Upton
| Site Technology Supervisor SignOnSanDiego.com
| Development & Integration The San Diego Union-Tribune
| 619.718.5241 sean.upton@uniontrib.com
| PATH_TO_THE_DARK_SIDE = 'c:\winnt\system32'
+-----------------------------------------------------------