[Zope-dev] Custom class: cut,copy,rename?

Max M maxm at mxm.dk
Mon Mar 1 19:21:04 EST 2004


Ian Beatty wrote:


 > Am I not inheriting from the proper set of base classes? Is there an 
easier
 > way? According to the ZDG (2.4 edition, vs. my Zope 2.7),
 > OFS.SimpleItem.Item (subclassed by OFS.SimpleItem.SimpleItem) is 
supposed to
 > provide cut-and-paste functionality. So, how might I be breaking it?


The order of the parent classes matters. Ie. Some methods are defined in 
SimpleItem that returns None. Clipped from the source::

     # This keeps simple items from acquiring their parents
     # objectValues, etc., when used in simple tree tags.
     def objectValues(self, spec=None):
         return ()
     objectIds=objectItems=objectValues


So if SimpleItem is before ObjectManager the traversal order of the 
parent objects will make shure that you get the wrong methods :-( So 
this will *not* work:


     class aSimpleItem(
          CatalogAware, PropertyManager,
          SimpleItem.SimpleItem, ObjectManager):


This order works:

     class aSimpleItem(
          CatalogAware, PropertyManager, SimpleItem):

     class anObjectManager(
          ObjectManager, aSimpleItem):


regards Max M



More information about the Zope-Dev mailing list