[Interface-dev] module-level interface

Jim Fulton jim at zope.com
Thu Jun 9 06:36:14 EDT 2005


John Lenton wrote:
> Well, this is what I came up with. It works for me, but I can't get
> the testing framework to work so it's untested outside of my own use
> case. What I've done is made it so that interfaces can contain other
> interfaces, which is then used by verifyObject to check that the
> object being verified contains an object that implements that
> interface.

This is different from what I thought you were asking for yesterday.
I thought you wanted to specify an object with an attribute that could
be called to get an object of some interface.

> Thus, in interfaces.py:
>   class IWindow(Interface): pass
>   class ISkin(Interface):
>     Window = IWindow
> and in the skin:
>   class Window(Container):
>     implements(IWindow)
> and in the skin loader:
>   skin = __import__(blah)
>   verifyObject(skin) # passes
> 
> I guess that interpreting an interface to mean an object implementing
> it (instead of providing it) is arbitrary and I should've written a
> couple of classes similar to the existing Attributes, right?

Right.  In fact, the zope.schema package has something like
this, the object field.

Jim

-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org


More information about the Interface-dev mailing list