RE: [Zope] custom __of__

2000-12-21 Thread Brian Lloyd

> 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[EMAIL PROTECTED]
Software Engineer  540.371.6909  
Digital Creations  http://www.digicool.com 




___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




[Zope] custom __of__

2000-12-20 Thread Randall F. Kern

This is something that I still don't quite understand.

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.

Thanks,
-Randy

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )