[Zope] custom __of__

Brian Lloyd brian@digicool.com
Thu, 21 Dec 2000 09:34:37 -0500


> I have a set of (python, Folder derived) objects, which are children of
> a Folder derived python class.  Each of these in turn has another,
> related python object.
> 
> /
> 	a
> 		ab1
> 		ab2
> 		ab3
> 	b1
> 	b2
> 	b3
> 
> When I access /a/ab1, I want b1 inserted into the acquisition hierarchy
> between a and ab1.  I've done this with __bobo_traverse__, but that
> doesn't help when you access ab1 as an attribute of a, such as when
> using objectValues().  So I thought I would try overriding __of__, like
> so in the ab class:
> 
> def __of__(self, parent):
> 	wparent = self._b.__of__(parent)
> 	return Folder.Folder.__of__(self, wparent)
> 
> But that doesn't work, I get this error on the return line:
> 	Error Type: TypeError
> 	Error Value: unbound C method must be called with Acquirer 1st
> argument
> 
> 
> Any ideas?  I'm pretty confused.

You need to use the 'inheritedAttribute' method for an 
ExtensionClass to call a superclass method that you 
have overridden. Try the following (where 'myABClass'
is the name of your class implmenting this __of__ method):


  def __of__(self, parent):
    wparent = self._b.__of__(parent)
    return myABClass.inheritedAttribute('__of__')(self, wparent)

Hope this helps!



Brian Lloyd        brian@digicool.com
Software Engineer  540.371.6909              
Digital Creations  http://www.digicool.com