[ZODB-Dev] Interfaces, extension classes, and BTrees?

Michel Pelletier michel@digicool.com
Thu, 3 May 2001 12:17:16 -0700 (PDT)


Ok, this is abit out of scope for this list, but since it's about BTrees I
figured I'd ask.

The BTrees packages comes with some interfaces written by Jim.  It apears
he didn't test them 1) because they contained syntax errors, and 2)
because the assertTypeImplements at the bottom of the module doesn't
work.  I'm guessing it's because these things are extension classes, not
types, like the previous incanation of BTrees were (see
lib/python/BTrees/Interfaces.py)

So instead, I'm doing a manual __implements__ assignment in
IOBTree.py, which seems to work well:

  >>> BTrees.IOBTree.IOBTree
  <extension class BTrees.IOBTree.IOBTree at 4030ef80>
  >>> BTrees.IOBTree.IOBTree.__implements__
  <Interface IBTree at 847848c>

The object does apear to implement the interface:

  >>> objectImplements(BTrees.IOBTree.IOBTree)
  [<Interface IBTree at 847848c>]

But the interface can't tell:

  >>> Interfaces.IBTree.isImplementedByInstancesOf(BTrees.IOBTree.IOBTree)
  0

This should succeed.  Do interfaces not grok ExtensionClasses?  Is
there some other way to do this for ExtensionClasses?

-Michel